<commit_before>import os.path
import logging
import tarfile
import tempfile

import zinc.helpers as helpers
import zinc.utils as utils
from zinc.models import ZincFileList, ZincManifest
from zinc.formats import Formats

log = logging.getLogger(__name__)

## TODO: real ignore system
IGNORE = ['.DS_Store']


## TODO: relocate?
def _build_archive(catalog, manifest, src_dir, flavor=None):

    bundle_id = helpers.make_bundle_id(catalog.id, manifest.bundle_name)
    bundle_descr = helpers.make_bundle_descriptor(bundle_id,
                                                  manifest.version,
                                                  flavor=flavor)
    archive_filename = '%s.tar' % (bundle_descr)

    archive_path = os.path.join(
            tempfile.mkdtemp(), archive_filename)

    files = manifest.get_all_files(flavor=flavor)

    with tarfile.open(archive_path, 'w') as tar:
        for f in files:
            format, format_info = manifest.get_format_info_for_file(f)
            assert format is not None
            assert format_info is not None
            sha = manifest.sha_for_file(f)
            ext = helpers.file_extension_for_format(format)

            path = os.path.join(src_dir, f)
            arcname = helpers.append_file_extension(sha, ext)

            ## TODO: write a test to ensure that file formats are written correctly

            if format == Formats.RAW:
                tar.add(path, arcname=arcname)

            elif format == Formats.GZ:
                gz_path = tempfile.mkstemp()[1]
                utils.gzip_path(path, gz_path)
                tar.add(gz_path, arcname)
                os.remove(gz_path)

    return archive_path


class ZincBundleUpdateTask(object):

    def __init__(self,
                 catalog=None,
                 bundle_name=None,
                 src_dir=None,
                 flavor_spec=None,
                 force=False,
                 skip_master_archive=True):

        self.catalog = catalog
        self.bundle_name = bundle_name
        self.flavor_spec = flavor_spec
        self.force = force
        self.skip_master_archive = skip_master_archive

        self._src_dir = src_dir

    @property
    def src_dir(self):
        return self._src_dir

    @src_dir.setter
    def src_dir(self, val):
        if val is not None:<commit_msg>Specifying positional parameter name<commit_after>import os.path
import logging
import tarfile
import tempfile

import zinc.helpers as helpers
import zinc.utils as utils
from zinc.models import ZincFileList, ZincManifest
from zinc.formats import Formats

log = logging.getLogger(__name__)

## TODO: real ignore system
IGNORE = ['.DS_Store']


## TODO: relocate?
def _build_archive(catalog, manifest, src_dir, flavor=None):

    bundle_id = helpers.make_bundle_id(catalog.id, manifest.bundle_name)
    bundle_descr = helpers.make_bundle_descriptor(bundle_id,
                                                  manifest.version,
                                                  flavor=flavor)
    archive_filename = '%s.tar' % (bundle_descr)

    archive_path = os.path.join(
            tempfile.mkdtemp(), archive_filename)

    files = manifest.get_all_files(flavor=flavor)

    with tarfile.open(archive_path, 'w') as tar:
        for f in files:
            format, format_info = manifest.get_format_info_for_file(f)
            assert format is not None
            assert format_info is not None
            sha = manifest.sha_for_file(f)
            ext = helpers.file_extension_for_format(format)

            path = os.path.join(src_dir, f)
            arcname = helpers.append_file_extension(sha, ext)

            ## TODO: write a test to ensure that file formats are written correctly

            if format == Formats.RAW:
                tar.add(path, arcname=arcname)

            elif format == Formats.GZ:
                gz_path = tempfile.mkstemp()[1]
                utils.gzip_path(path, gz_path)
                tar.add(gz_path, arcname=arcname)
                os.remove(gz_path)

    return archive_path


class ZincBundleUpdateTask(object):

    def __init__(self,
                 catalog=None,
                 bundle_name=None,
                 src_dir=None,
                 flavor_spec=None,
                 force=False,
                 skip_master_archive=True):

        self.catalog = catalog
        self.bundle_name = bundle_name
        self.flavor_spec = flavor_spec
        self.force = force
        self.skip_master_archive = skip_master_archive

        self._src_dir = src_dir

    @property
    def src_dir(self):
        return self._src_dir

    @src_dir.setter
    def src_dir(self, val):
        if val is not None:
{'fraction_non_alphanumeric': 0.07561235356762513, 'fraction_numerical': 0.0004259850905218317, 'mean_word_length': 2.03751617076326, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5404572', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1317, 'n_words': 308}