def parse_metadata(path):
    '''
    Attempts to parse out metadata from django comments.
    Each comment is assumed to be key = value where the value is a JSON object.
    '''
    # Match Django template comments.
    PATTERN = re.compile(r'^{#\s?(?P<name>\w+)\s?=\s?(?P<value>[\S\s]+)\s?#}')

    # Check only the start of the file.
    lines = io.open(path, encoding='utf-8').read().splitlines()[:100]
    lines = map(strip, lines)
    meta = dict()
    for line in lines:
        m = PATTERN.search(line)
        if m:
            name, value = m.group('name'), m.group('value')
            try:
                obj = json.loads(value)
            except __HOLE__ as exc:
                obj = str(value)
            meta[name] = obj
    # logger.debug("path: {}, metadata: {}".format(path, meta))
    return meta
dataset/ETHPy150Open ialbert/pyblue/pyblue/engine.py/parse_metadata