<commit_before>#!/usr/bin/env python
import os.path
import re
import sys
import tempfile
import zipfile
import wheel.bdist_wheel
import distutils.dist
from distutils.archive_util import make_archive

egg_info_re = re.compile(r'''(?P<name>.+?)-(?P<ver>.+?)
    (-(?P<pyver>.+?))?(-(?P<arch>.+?))?.egg''', re.VERBOSE)

if __name__ == "__main__":
    egg_path = sys.argv[1]
    egg_info = egg_info_re.match(os.path.basename(egg_path)).groupdict()
    egg = zipfile.ZipFile(sys.argv[1])
    dir = tempfile.mkdtemp(suffix="_e2w")
    egg.extractall(dir)
    abi = 'noabi'
    dist_info = "%s-%s" % (egg_info['name'], egg_info['ver'])
    wheel_name = '-'.join((
            dist_info,
            egg_info['pyver'].replace('.', ''),
            (egg_info['arch'] or 'noarch').replace('.', '_').replace('-', '_')
            ))
    bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution())
    bw.root_is_purelib = egg_info['arch'] is None
    dist_info_dir = os.path.join(dir, '%s.dist-info' % dist_info)
    bw.egg2dist(os.path.join(dir, 'EGG-INFO'),
                dist_info_dir)
    bw.write_wheelfile(dist_info_dir)
    bw.write_record(dir, dist_info_dir)
    filename = make_archive(wheel_name, 'zip', root_dir=dir)
    os.rename(filename, filename[:-3] + 'whl')
<commit_msg>egg2wheel tweaks<commit_after>#!/usr/bin/env python
import os.path
import re
import sys
import tempfile
import zipfile
import wheel.bdist_wheel
import distutils.dist
from distutils.archive_util import make_archive

egg_info_re = re.compile(r'''(?P<name>.+?)-(?P<ver>.+?)
    (-(?P<pyver>.+?))?(-(?P<arch>.+?))?.egg''', re.VERBOSE)

if __name__ == "__main__":
    egg_path = sys.argv[1]
    egg_info = egg_info_re.match(os.path.basename(egg_path)).groupdict()
    egg = zipfile.ZipFile(sys.argv[1])
    dir = tempfile.mkdtemp(suffix="_e2w")
    egg.extractall(dir)
    dist_info = "%s-%s" % (egg_info['name'], egg_info['ver'])
    abi = 'noabi'
    pyver = egg_info['pyver'].replace('.', '')
    arch = (egg_info['arch'] or 'noarch').replace('.', '_').replace('-', '_')
    if arch != 'noarch':
        # assume all binary eggs are for CPython
        pyver = 'cp' + arch[2:]
    wheel_name = '-'.join((
            dist_info,
            pyver,
            abi,
            arch
            ))
    bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution())
    bw.root_is_purelib = egg_info['arch'] is None
    dist_info_dir = os.path.join(dir, '%s.dist-info' % dist_info)
    bw.egg2dist(os.path.join(dir, 'EGG-INFO'),
                dist_info_dir)
    bw.write_wheelfile(dist_info_dir)
    bw.write_record(dir, dist_info_dir)
    filename = make_archive(wheel_name, 'zip', root_dir=dir)
    os.rename(filename, filename[:-3] + 'whl')

{'fraction_non_alphanumeric': 0.1810850439882698, 'fraction_numerical': 0.004398826979472141, 'mean_word_length': 3.387459807073955, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2440955', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1014, 'n_words': 165}