# Path: lib/utilities.py
# TOKENIZER = None
# ACK_LANGUAGE_MAP = {
#     'c': 'cc',
#     'c++': 'cpp',
#     'c#': 'csharp',
#     'objective-c': 'objc',
#     'ojective-c++': 'objcpp',
# }
# def get_cache_hits():
# def get_loc(path, files=None):
# def search(
#     pattern, path, recursive=True, whole=False, ignorecase=False, include=None,
#     exclude=None
# ):
# def url_to_json(url, headers={}):
# def get_repo_path(repo_id, repositories_dir):
# def clone(owner, name, directory, date=None):
# def read(jsonfile):
# def parse_datetime_delta(datetime_delta):
# def is_cloneable(owner, name):
# def get_files(path, language):


from lib import utilities
    from lib.core import Tokenizer
    from lib.utilities import url_to_json
    ),                                                 # BSD 3- and 2-clause
    'Artistic License',                                # Artistic License
    'http://www.apache.org/licenses',                  # Apache License
    'GNU AFFERO GENERAL PUBLIC LICENSE',               # GNU AGPL
]


def run(project_id, repo_path, cursor, **options):
    cursor.execute('''
        SELECT
            url
        FROM
            projects
        WHERE
            id = {0}
        '''.format(project_id))

    record = cursor.fetchone()

    full_url = utilities.TOKENIZER.tokenize(record[0].rstrip())
    json_response = url_to_json(full_url, headers={
            'Accept': 'application/vnd.github.drax-preview+json'
        }
    )

    result = True if 'license' in json_response \
                     and json_response['license'] else False

    if not result:
        for pattern in LICENSE_PATTERNS:

# Path: lib/utilities.py
# TOKENIZER = None
# ACK_LANGUAGE_MAP = {
#     'c': 'cc',
#     'c++': 'cpp',
#     'c#': 'csharp',
#     'objective-c': 'objc',
#     'ojective-c++': 'objcpp',
# }
# def get_cache_hits():
# def get_loc(path, files=None):
# def search(
#     pattern, path, recursive=True, whole=False, ignorecase=False, include=None,
#     exclude=None
# ):
# def url_to_json(url, headers={}):
# def get_repo_path(repo_id, repositories_dir):
# def clone(owner, name, directory, date=None):
# def read(jsonfile):
# def parse_datetime_delta(datetime_delta):
# def is_cloneable(owner, name):
# def get_files(path, language):


# Path: attributes/license/main.py
from lib import utilities
    from lib.core import Tokenizer
    from lib.utilities import url_to_json

    ),                                                 # BSD 3- and 2-clause
    'Artistic License',                                # Artistic License
    'http://www.apache.org/licenses',                  # Apache License
    'GNU AFFERO GENERAL PUBLIC LICENSE',               # GNU AGPL
]


def run(project_id, repo_path, cursor, **options):
    cursor.execute('''
        SELECT
            url
        FROM
            projects
        WHERE
            id = {0}
        '''.format(project_id))

    record = cursor.fetchone()

    full_url = utilities.TOKENIZER.tokenize(record[0].rstrip())
    json_response = url_to_json(full_url, headers={
            'Accept': 'application/vnd.github.drax-preview+json'
        }
    )

    result = True if 'license' in json_response \
                     and json_response['license'] else False

    if not result:
        for pattern in LICENSE_PATTERNS:

            if utilities.search(pattern, repo_path, ignorecase=True):