# Path: website/project/metadata/schemas.py
# def get_osf_meta_schemas():
#     """Returns the current contents of all known schema files."""
#     schemas = [
#         ensure_schema_structure(from_json(json_filename))
#         for json_filename in OSF_META_SCHEMA_FILES
#     ]
#     return schemas


from past.builtins import basestring
from math import ceil
from contextlib import contextmanager
from django.apps import apps
from django.db import connection
from django.db.migrations.operations.base import Operation
from osf.models.base import generate_object_id
from osf.utils.sanitize import strip_html, unescape_entities
from website import settings
from website.project.metadata.schemas import get_osf_meta_schemas
        from osf.models import NodeLicense
    from osf.models import NodeLicense
    from osf.models import RegistrationSchema
    from osf.models import RegistrationSchemaBlock
import os
import itertools
import builtins
import json
import logging
import warnings
                nupdated += 1

            logger.info('License {name} ({id}) added to the database.'.format(name=name, id=id))

    logger.info('{} licenses inserted into the database, {} licenses updated in the database.'.format(
        ninserted, nupdated
    ))

    return ninserted, nupdated


def remove_licenses(*args):

    pre_count = NodeLicense.objects.all().count()
    NodeLicense.objects.all().delete()

    logger.info('{} licenses removed from the database.'.format(pre_count))


def ensure_schemas(*args):
    """Import meta-data schemas from JSON to database if not already loaded
    """
    state = args[0] if args else apps
    schema_count = 0
    try:
        schema_model = state.get_model('osf', 'registrationschema')
    except LookupError:
        # Use MetaSchema model if migrating from a version before RegistrationSchema existed
        schema_model = state.get_model('osf', 'metaschema')


# Path: website/project/metadata/schemas.py
# def get_osf_meta_schemas():
#     """Returns the current contents of all known schema files."""
#     schemas = [
#         ensure_schema_structure(from_json(json_filename))
#         for json_filename in OSF_META_SCHEMA_FILES
#     ]
#     return schemas


# Path: osf/utils/migrations.py
from past.builtins import basestring
from math import ceil
from contextlib import contextmanager
from django.apps import apps
from django.db import connection
from django.db.migrations.operations.base import Operation
from osf.models.base import generate_object_id
from osf.utils.sanitize import strip_html, unescape_entities
from website import settings
from website.project.metadata.schemas import get_osf_meta_schemas
        from osf.models import NodeLicense
    from osf.models import NodeLicense
    from osf.models import RegistrationSchema
    from osf.models import RegistrationSchemaBlock
import os
import itertools
import builtins
import json
import logging
import warnings

                nupdated += 1

            logger.info('License {name} ({id}) added to the database.'.format(name=name, id=id))

    logger.info('{} licenses inserted into the database, {} licenses updated in the database.'.format(
        ninserted, nupdated
    ))

    return ninserted, nupdated


def remove_licenses(*args):

    pre_count = NodeLicense.objects.all().count()
    NodeLicense.objects.all().delete()

    logger.info('{} licenses removed from the database.'.format(pre_count))


def ensure_schemas(*args):
    """Import meta-data schemas from JSON to database if not already loaded
    """
    state = args[0] if args else apps
    schema_count = 0
    try:
        schema_model = state.get_model('osf', 'registrationschema')
    except LookupError:
        # Use MetaSchema model if migrating from a version before RegistrationSchema existed
        schema_model = state.get_model('osf', 'metaschema')


    for schema in get_osf_meta_schemas():