def _build_metadata(): 
<EOL>expected_keys = ('<STR_LIT:url>', '<STR_LIT:version>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>metadata = {}<EOL>with io.open(srcfile('<STR_LIT:src>', package_name, '<STR_LIT>'), encoding='<STR_LIT:utf-8>') as handle:<EOL><INDENT>pkg_init = handle.read()<EOL>metadata['<STR_LIT>'] = re.search(r'<STR_LIT>', pkg_init, re.DOTALL|re.MULTILINE).group(<NUM_LIT:1>)<EOL>for line in pkg_init.splitlines():<EOL><INDENT>match = re.match(r"""<STR_LIT>""".format('<STR_LIT:|>'.join(expected_keys)), line)<EOL>if match:<EOL><INDENT>metadata[match.group(<NUM_LIT:1>)] = match.group(<NUM_LIT:3>)<EOL><DEDENT><DEDENT><DEDENT>if not all(i in metadata for i in expected_keys):<EOL><INDENT>raise RuntimeError("<STR_LIT>"<EOL>.format(name, '<STR_LIT:U+002CU+0020>'.join(sorted(set(expected_keys) - set(metadata.keys()))),))<EOL><DEDENT>text = metadata['<STR_LIT>'].strip()<EOL>if text:<EOL><INDENT>metadata['<STR_LIT:description>'], text = text.split('<STR_LIT:.>', <NUM_LIT:1>)<EOL>metadata['<STR_LIT:description>'] = '<STR_LIT:U+0020>'.join(metadata['<STR_LIT:description>'].split()).strip() + '<STR_LIT:.>' <EOL>metadata['<STR_LIT>'] = textwrap.dedent(text).strip()<EOL><DEDENT>metadata['<STR_LIT>'] = metadata['<STR_LIT>'].replace('<STR_LIT:U+002C>', '<STR_LIT:U+0020>').strip().split()<EOL>requirements_files = dict(<EOL>install = '<STR_LIT>',<EOL>setup = '<STR_LIT>',<EOL>test = '<STR_LIT>',<EOL>)<EOL>requires = {}<EOL>for key, filename in requirements_files.items():<EOL><INDENT>requires[key] = []<EOL>if os.path.exists(srcfile(filename)):<EOL><INDENT>with io.open(srcfile(filename), encoding='<STR_LIT:utf-8>') as handle:<EOL><INDENT>for line in handle:<EOL><INDENT>line = line.strip()<EOL>if line and not line.startswith('<STR_LIT:#>'):<EOL><INDENT>if any(line.startswith(i) for i in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')):<EOL><INDENT>line = line.split('<STR_LIT>')[<NUM_LIT:1>]<EOL><DEDENT>requires[key].append(line)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if not any('<STR_LIT>' == re.split('<STR_LIT>', i.lower())[<NUM_LIT:0>] for i in requires['<STR_LIT:test>']):<EOL><INDENT>requires['<STR_LIT:test>'].append('<STR_LIT>') <EOL><DEDENT>console_scripts = []<EOL>for path, dirs, files in os.walk(srcfile('<STR_LIT:src>', package_name)):<EOL><INDENT>dirs = [i for i in dirs if not i.startswith('<STR_LIT:.>')]<EOL>if '<STR_LIT>' in files:<EOL><INDENT>path = path[len(srcfile('<STR_LIT:src>') + os.sep):]<EOL>appname = path.split(os.sep)[-<NUM_LIT:1>]<EOL>with io.open(srcfile('<STR_LIT:src>', path, '<STR_LIT>'), encoding='<STR_LIT:utf-8>') as handle:<EOL><INDENT>for line in handle.readlines():<EOL><INDENT>match = re.match(r"""<STR_LIT>""", line)<EOL>if match:<EOL><INDENT>appname = match.group(<NUM_LIT:2>)<EOL><DEDENT><DEDENT><DEDENT>console_scripts.append('<STR_LIT>'.format(appname, path.replace(os.sep, '<STR_LIT:.>')))<EOL><DEDENT><DEDENT>candidate_files = [<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>]<EOL>data_files = defaultdict(list)<EOL>for filename in candidate_files:<EOL><INDENT>if os.path.exists(srcfile(filename)):<EOL><INDENT>data_files['<STR_LIT>'].append(filename)<EOL><DEDENT><DEDENT>classifiers = []<EOL>for classifiers_txt in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>classifiers_txt = srcfile(classifiers_txt)<EOL>if os.path.exists(classifiers_txt):<EOL><INDENT>with io.open(classifiers_txt, encoding='<STR_LIT:utf-8>') as handle:<EOL><INDENT>classifiers = [i.strip() for i in handle if i.strip() and not i.startswith('<STR_LIT:#>')]<EOL><DEDENT>break<EOL><DEDENT><DEDENT>entry_points.setdefault('<STR_LIT>', []).extend(console_scripts)<EOL>metadata.update(dict(<EOL>name = name,<EOL>package_dir = {'<STR_LIT>': '<STR_LIT:src>'},<EOL>packages = find_packages(srcfile('<STR_LIT:src>'), exclude=['<STR_LIT>']),<EOL>data_files = data_files.items(),<EOL>zip_safe = False,<EOL>include_package_data = True,<EOL>install_requires = requires['<STR_LIT>'],<EOL>setup_requires = requires['<STR_LIT>'],<EOL>tests_require =  requires['<STR_LIT:test>'],<EOL>classifiers = classifiers,<EOL>cmdclass = dict(<EOL>test = PyTest,<EOL>),<EOL>entry_points = entry_points,<EOL>))<EOL>return metadata<EOL>
Return project's metadata as a dict.