def egg2dist(self, egginfo_path, distinfo_path):
def adios(p):<EOL><INDENT>"""<STR_LIT>"""<EOL>if os.path.exists(p) and not os.path.islink(p) and os.path.isdir(p):<EOL><INDENT>shutil.rmtree(p)<EOL><DEDENT>elif os.path.exists(p):<EOL><INDENT>os.unlink(p)<EOL><DEDENT><DEDENT>adios(distinfo_path)<EOL>if not os.path.exists(egginfo_path):<EOL><INDENT>import glob<EOL>pat = os.path.join(os.path.dirname(egginfo_path), '<STR_LIT>')<EOL>possible = glob.glob(pat)<EOL>err = "<STR_LIT>" % (egginfo_path,)<EOL>if possible:<EOL><INDENT>alt = os.path.basename(possible[<NUM_LIT:0>])<EOL>err += "<STR_LIT>" % (alt,)<EOL><DEDENT>raise ValueError(err)<EOL><DEDENT>if os.path.isfile(egginfo_path):<EOL><INDENT>pkginfo_path = egginfo_path<EOL>pkg_info = self._pkginfo_to_metadata(egginfo_path, egginfo_path)<EOL>os.mkdir(distinfo_path)<EOL><DEDENT>else:<EOL><INDENT>pkginfo_path = os.path.join(egginfo_path, '<STR_LIT>')<EOL>pkg_info = self._pkginfo_to_metadata(egginfo_path, pkginfo_path)<EOL>shutil.copytree(egginfo_path, distinfo_path,<EOL>ignore=lambda x, y: set(('<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',)))<EOL>dependency_links_path = os.path.join(distinfo_path, '<STR_LIT>')<EOL>with open(dependency_links_path, '<STR_LIT:r>') as dependency_links_file:<EOL><INDENT>dependency_links = dependency_links_file.read().strip()<EOL><DEDENT>if not dependency_links:<EOL><INDENT>adios(dependency_links_path)<EOL><DEDENT><DEDENT>write_pkg_info(os.path.join(distinfo_path, '<STR_LIT>'), pkg_info)<EOL>metadata_path = os.path.join(distinfo_path, '<STR_LIT>')<EOL>self.add_requirements(metadata_path)<EOL>metadata_json_path = os.path.join(distinfo_path, '<STR_LIT>')<EOL>pymeta = pkginfo_to_dict(metadata_path,<EOL>distribution=self.distribution)<EOL>if '<STR_LIT:description>' in pymeta:<EOL><INDENT>description_filename = '<STR_LIT>'<EOL>description_text = pymeta.pop('<STR_LIT:description>')<EOL>description_path = os.path.join(distinfo_path,<EOL>description_filename)<EOL>with open(description_path, "<STR_LIT:wb>") as description_file:<EOL><INDENT>description_file.write(description_text.encode('<STR_LIT:utf-8>'))<EOL><DEDENT>pymeta['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT:description>'] = description_filename<EOL><DEDENT>license = self.license_file()<EOL>if license:<EOL><INDENT>license_filename = '<STR_LIT>'<EOL>shutil.copy(license, os.path.join(self.distinfo_dir, license_filename))<EOL>pymeta['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT>'] = license_filename<EOL><DEDENT>with open(metadata_json_path, "<STR_LIT:w>") as metadata_json:<EOL><INDENT>json.dump(pymeta, metadata_json, sort_keys=True)<EOL><DEDENT>adios(egginfo_path)<EOL>
Convert an .egg-info directory into a .dist-info directory