<commit_before>"""esky extension

Extends the 'bdist_esky' command with the 'create-zipfile' option to allow not
creating a zip file of the esky freeze.
"""

import sys
from esky.bdist_esky import bdist_esky as e_bdist_esky


class bdist_esky(e_bdist_esky):

    e_bdist_esky.user_options.append(
        ('create-zipfile=', None, "create zip file from esky freeze"))

    def initialize_options(self):
        e_bdist_esky.initialize_options(self)
        self.create_zipfile = False

    def _run(self):
        self._run_initialise_dirs()
        if self.pre_freeze_callback is not None:
            self.pre_freeze_callback(self)
        self._run_freeze_scripts()
        if self.pre_zip_callback is not None:
            self.pre_zip_callback(self)
        # Only create zip file from esky freeze if option is passed
        if self.create_zipfile:
            self._run_create_zipfile()

# Monkey-patch distutils to override bdist_esky command included in
# esky.bdist_esky.
sys.modules["distutils.command.bdist_esky"] = sys.modules["nx_esky"]
<commit_msg>NXDRIVE-40: Allow to not remove esky freeze output directory after zipping it<commit_after>"""esky extension

Extends the 'bdist_esky' command with the 'create-zipfile' option to allow not
creating a zip file of the esky freeze.
"""

import sys
import os
from esky.bdist_esky import bdist_esky as e_bdist_esky
from esky.util import get_platform
from esky.util import create_zipfile
from esky.util import really_rmtree


class bdist_esky(e_bdist_esky):

    e_bdist_esky.user_options.append(
        ('create-zipfile=', None, "create zip file from esky freeze"))
    e_bdist_esky.user_options.append(
        ('rm-freeze-dir-after-zipping=', None, "remove esky freeze directory"
         " after zipping it"))

    def initialize_options(self):
        e_bdist_esky.initialize_options(self)
        self.create_zipfile = False
        self.rm_freeze_dir_after_zipping = True

    def _run(self):
        self._run_initialise_dirs()
        if self.pre_freeze_callback is not None:
            self.pre_freeze_callback(self)
        self._run_freeze_scripts()
        if self.pre_zip_callback is not None:
            self.pre_zip_callback(self)
        # Only create zip file from esky freeze if option is passed
        if self.create_zipfile:
            self._run_create_zipfile()

    def _run_create_zipfile(self):
        """Zip up the final distribution."""
        print "zipping up the esky"
        fullname = self.distribution.get_fullname()
        platform = get_platform()
        zfname = os.path.join(self.dist_dir,
                              "%s.%s.zip" % (fullname, platform, ))
        if hasattr(self.freezer_module, "zipit"):
            self.freezer_module.zipit(self, self.bootstrap_dir, zfname)
        else:
            create_zipfile(self.bootstrap_dir, zfname, compress=True)
        # Only remove bootstrap dir if option is passed
        if self.rm_freeze_dir_after_zipping:
            really_rmtree(self.bootstrap_dir)

# Monkey-patch distutils to override bdist_esky command included in
# esky.bdist_esky.
sys.modules["distutils.command.bdist_esky"] = sys.modules["nx_esky"]

{'fraction_non_alphanumeric': 0.08165195460277427, 'fraction_numerical': 0.0006305170239596469, 'mean_word_length': 3.110103626943005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3905828', 'n_tokens_mistral': 1023, 'n_tokens_neox': 1010, 'n_words': 251}