id int64 0 1.29M | original_id stringlengths 32 32 | swhid stringlengths 100 170 | sha1 stringlengths 40 40 | repo_name stringlengths 2 45 | repo_group stringclasses 12
values | filepath stringlengths 5 153 | name stringlengths 1 14.9k | type stringclasses 3
values | code stringlengths 7 2.12M |
|---|---|---|---|---|---|---|---|---|---|
700 | f05c140438827dc48d99c8e66b896a22 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=427-428/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | SquashFSArchive::_absolute_path(self, path) | function | def _absolute_path(self, path):
return os.path.normpath(os.path.join(self._staging_dir, path)) |
701 | 731007a9eb28b772e20502decb84e7db | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=434-458/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | SquashFSArchive::_add(self, source, target) | function | def _add(self, source, target):
target_abspath = self._absolute_path(target)
self._ensure_parent(target_abspath)
# hardlink instead of copy is faster, but it doesn't work across devices
same_device = os.lstat(source).st_dev == os.lstat(os.path.dirname(target_abspath)).st_dev
if ... |
702 | 447e8d9c2b612dcef4e09b21aec67f9f | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=180-184/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelGzipFileWriter::_write_header(self) | function | def _write_header(self):
self.fileobj.write(b'\037\213\010')
self.fileobj.write(b'\x00')
self._write32u(int(time.time()))
self.fileobj.write(b'\002\377') |
703 | 3e2b3ae0c03143724830a0e23e7f56b1 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=207-208/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelBZ2FileWriter::_write_header(self) | function | def _write_header(self):
pass |
704 | 00c76aa69b33b93e49c907a2dc1e042c | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=241-243/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ArchiveBase::add(self, source, target) | function | def add(self, source, target):
target = os.path.join(self.arcroot, target)
self._add(source, target) |
705 | e1778f9acad866b7e480353a3e6711d2 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=297-301/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ZipArchive::__init__(self, fileobj, arcroot, zip_symlinks=False, zip_64=True) | function | def __init__(self, fileobj, arcroot, zip_symlinks=False, zip_64=True):
self.fileobj = fileobj
self.arcroot = arcroot
self.zip_symlinks = zip_symlinks
self.zip_64 = zip_64 |
706 | 2328fd52e5c190d1c35094b1f0dcf6d3 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=170-172/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelGzipFileWriter::_new_compressor(self) | function | def _new_compressor(self):
return zlib.compressobj(self.compresslevel, zlib.DEFLATED,
-zlib.MAX_WBITS, zlib.DEF_MEM_LEVEL, 0) |
707 | 70e5356ae2ca1d1ea8b566106b81e312 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=186-189/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelGzipFileWriter::_write_footer(self) | function | def _write_footer(self):
self.fileobj.write(self._new_compressor().flush(zlib.Z_FINISH))
self._write32u(self.crc)
self._write32u(self.size & 0xffffffff) |
708 | bf6fb1fc2a241fd14d07fdfd3de7b83f | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=191-192/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelGzipFileWriter::_flush_compressor(self, compressor) | function | def _flush_compressor(self, compressor):
return compressor.flush(zlib.Z_FULL_FLUSH) |
709 | f5f45e207148689715181fda11914f68 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=210-211/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelBZ2FileWriter::_write_footer(self) | function | def _write_footer(self):
pass |
710 | fed58deff505b3da53b21e6f61b830d6 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=227-228/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelXZFileWriter::_per_buffer_op(self, buffer) | function | def _per_buffer_op(self, buffer):
pass |
711 | 472e04eabae6c290fa2def011100c2b4 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=245-247/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ArchiveBase::add_bytes(self, source, sourcebytes, target) | function | def add_bytes(self, source, sourcebytes, target):
target = os.path.join(self.arcroot, target)
self._add_bytes(source, sourcebytes, target) |
712 | f5f628f8717c669aa8fdc71ac7f6ab77 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=303-307/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ZipArchive::__enter__(self) | function | def __enter__(self):
self.archive = zipfile.ZipFile(self.fileobj, "w",
allowZip64=self.zip_64,
compression=zipfile.ZIP_DEFLATED)
return self |
713 | c5414efc3e0f9b5412da8ffd81aa0c42 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=358-360/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ZipArchive::_add_bytes(self, source, sourcebytes, target) | function | def _add_bytes(self, source, sourcebytes, target):
info = zipinfo_from_file(source, target)
self.archive.writestr(info, sourcebytes) |
714 | a3ea12c17190d2e8bf190adcfbd1c884 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=217-237/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelXZFileWriter | type | class ParallelXZFileWriter(ParallelFileWriter):
def _init_state(self):
# from `man lzma`: uses dict sizes between 64 kb and 32 MB for the level presets.
# 2-4 times the size (minimum 1 MB) is best for the block size.
self._block_size = 4 * max(1, (2**(self.compresslevel - 4))) * 2**10 * 2**1... |
715 | 4aac170d0b036d1edfa07f4ec41f225f | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=158-192/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelGzipFileWriter | type | class ParallelGzipFileWriter(ParallelFileWriter):
# Since it's hard for us to keep a running dictionary (a serial operation)
# with parallel compression of blocks, we use a blocksize > a few factors
# bigger than the max dict size (32 KiB). In practice this is fine - we
# only lose out by a small factor... |
716 | 0b7274c89635d71a4b7a080f2950f8a4 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=250-280/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | TarArchive | type | class TarArchive(ArchiveBase):
def __init__(self, fileobj, arcroot, close_file=False,
mode='w', compresslevel=4):
self.fileobj = fileobj
self.arcroot = arcroot
self.close_file = close_file
self.mode = mode
self.compresslevel = compresslevel
def __enter__... |
717 | 3ec3edca0ca239e576d9195e3ffb564b | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=296-360/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ZipArchive | type | class ZipArchive(ArchiveBase):
def __init__(self, fileobj, arcroot, zip_symlinks=False, zip_64=True):
self.fileobj = fileobj
self.arcroot = arcroot
self.zip_symlinks = zip_symlinks
self.zip_64 = zip_64
def __enter__(self):
self.archive = zipfile.ZipFile(self.fileobj, "w"... |
718 | 1c7d272fda3e0f2fbbaedee05646f227 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=78-155/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelFileWriter | type | class ParallelFileWriter:
def __init__(self, fileobj, compresslevel=9, n_threads=1):
self.fileobj = fileobj
self.compresslevel = compresslevel
self.n_threads = n_threads
# Initialize file state
self.size = 0
self._init_state()
self._write_header()
# ... |
719 | 9b8efe1a1a91ea6b15c2d121e4f7e233 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=195-214/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ParallelBZ2FileWriter | type | class ParallelBZ2FileWriter(ParallelFileWriter):
def _init_state(self):
# bzip2 compresslevel dictates its blocksize of 100 - 900 kb
self._block_size = self.compresslevel * 100 * 2**10
def _new_compressor(self):
import bz2
return bz2.BZ2Compressor(self.compresslevel)
def _p... |
720 | e32e607afdd07dfe7168a3e721a4b755 | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=240-247/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | ArchiveBase | type | class ArchiveBase:
def add(self, source, target):
target = os.path.join(self.arcroot, target)
self._add(source, target)
def add_bytes(self, source, sourcebytes, target):
target = os.path.join(self.arcroot, target)
self._add_bytes(source, sourcebytes, target) |
721 | 48b3a7419489592fe08bf5815d0bbafd | swh:1:cnt:3a736da20e4df71c6e683ed942a88c6cfce0ce56;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=366-465/ | ad231d08f7023dc0e37aa679805d9e49790c38c1 | conda-pack | analytics | conda_pack/formats.py | SquashFSArchive | type | class SquashFSArchive(ArchiveBase):
def __init__(self, fileobj, target_path, arcroot, n_threads, verbose=False,
compress_level=4):
if shutil.which("mksquashfs") is None:
raise SystemError("Command 'mksquashfs' not found. Please install it, "
"e.g. '... |
722 | 8b0e3f6f1a201fe25a8f5383216920c3 | swh:1:cnt:a2e0d0bd8c59f654da2985d1903faf86bd98d000;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=59-74/ | fed3186b01e25808f4fa81a02979d2491a510d93 | conda-pack | analytics | conda_pack/prefixes.py | update_prefix(path, new_prefix, placeholder, mode='text') | function | def update_prefix(path, new_prefix, placeholder, mode='text'):
if on_win and mode == 'text':
# force all prefix replacements to forward slashes to simplify need to
# escape backslashes replace with unix-style path separators
new_prefix = new_prefix.replace('\\', '/')
with open(path, 'rb... |
723 | 759d07f3da322f4f37cc211b3a7f25f8 | swh:1:cnt:a2e0d0bd8c59f654da2985d1903faf86bd98d000;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=110-123/ | fed3186b01e25808f4fa81a02979d2491a510d93 | conda-pack | analytics | conda_pack/prefixes.py | binary_replace(data, placeholder, new_prefix) | function | def binary_replace(data, placeholder, new_prefix):
"""Perform a binary replacement of `data`, where ``placeholder`` is
replaced with ``new_prefix`` and the remaining string is padded with null
characters. All input arguments are expected to be bytes objects."""
def replace(match):
... |
724 | 4b172e3b123b4e32f7720300ab19129a | swh:1:cnt:a2e0d0bd8c59f654da2985d1903faf86bd98d000;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=96-97/ | fed3186b01e25808f4fa81a02979d2491a510d93 | conda-pack | analytics | conda_pack/prefixes.py | text_replace(data, placeholder, new_prefix) | function | def text_replace(data, placeholder, new_prefix):
return data.replace(placeholder.encode('utf-8'), new_prefix.encode('utf-8')) |
725 | a9c4aa0fd84d074f83faaf5bdb6eb59d | swh:1:cnt:a2e0d0bd8c59f654da2985d1903faf86bd98d000;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=77-93/ | fed3186b01e25808f4fa81a02979d2491a510d93 | conda-pack | analytics | conda_pack/prefixes.py | replace_prefix(data, mode, placeholder, new_prefix) | function | def replace_prefix(data, mode, placeholder, new_prefix):
if mode == 'text':
data2 = text_replace(data, placeholder, new_prefix)
elif mode == 'binary':
data2 = binary_replace(data,
placeholder.encode('utf-8'),
new_prefix.encode('utf-8'... |
726 | 1be7842c98900486232532a78246ab16 | swh:1:cnt:a2e0d0bd8c59f654da2985d1903faf86bd98d000;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=115-120/ | fed3186b01e25808f4fa81a02979d2491a510d93 | conda-pack | analytics | conda_pack/prefixes.py | binary_replace::replace(match) | function | def replace(match):
occurances = match.group().count(placeholder)
padding = (len(placeholder) - len(new_prefix)) * occurances
if padding < 0:
raise ValueError("negative padding")
return match.group().replace(placeholder, new_prefix) + b'\0' * padding |
727 | 0fe8141ef9620f8de41e658a6368a310 | swh:1:cnt:a2e0d0bd8c59f654da2985d1903faf86bd98d000;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=126-171/ | fed3186b01e25808f4fa81a02979d2491a510d93 | conda-pack | analytics | conda_pack/prefixes.py | replace_pyzzer_entry_point_shebang(all_data, placeholder, new_prefix) | function | def replace_pyzzer_entry_point_shebang(all_data, placeholder, new_prefix):
"""Code adapted from pyzzer. This is meant to deal with entry point exe's
created by distlib, which consist of a launcher, then a shebang, then a zip
archive of the entry point code to run. We need to change the shebang.
"""
... |
728 | 6833896184811944d6cf83eb2535dac5 | swh:1:cnt:cca2b370a5b44b2ad301c6f86643ee7dd1ac864f;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=57-65/ | 8f1ba7f87211e41b75fe84d3ce1acae6aaf4e33e | conda-pack | analytics | conda_pack/_progress.py | progressbar::__enter__(self) | function | def __enter__(self):
if self._enabled:
self._start_time = default_timer()
# Start background thread
self._running = True
self._timer = threading.Thread(target=self._timer_func)
self._timer.daemon = True
self._timer.start()
return se... |
729 | 925b442a293cbbf5b457249b43fd849f | swh:1:cnt:cca2b370a5b44b2ad301c6f86643ee7dd1ac864f;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=77-80/ | 8f1ba7f87211e41b75fe84d3ce1acae6aaf4e33e | conda-pack | analytics | conda_pack/_progress.py | progressbar::__iter__(self) | function | def __iter__(self):
for i in self._iterable:
self._ndone += 1
yield i |
730 | 8d6c011ff22adaa3ff2ae916f2b4fedf | swh:1:cnt:cca2b370a5b44b2ad301c6f86643ee7dd1ac864f;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=7-22/ | 8f1ba7f87211e41b75fe84d3ce1acae6aaf4e33e | conda-pack | analytics | conda_pack/_progress.py | format_time(t) | function | def format_time(t):
"""Format seconds into a human readable form.
>>> format_time(10.4)
'10.4s'
>>> format_time(1000.4)
'16min 40.4s'
"""
m, s = divmod(t, 60)
h, m = divmod(m, 60)
if h:
return f"{h:2.0f}hr {m:2.0f}min {s:4.1f}s"
elif m:
return f"{m:2.0f}min {s:4.... |
731 | 187f4e7663274b8416e3c84232191cdd | swh:1:cnt:cca2b370a5b44b2ad301c6f86643ee7dd1ac864f;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=49-55/ | 8f1ba7f87211e41b75fe84d3ce1acae6aaf4e33e | conda-pack | analytics | conda_pack/_progress.py | progressbar::__init__(self, iterable, width=40, enabled=True, file=None) | function | def __init__(self, iterable, width=40, enabled=True, file=None):
self._iterable = iterable
self._ndone = 0
self._ntotal = len(iterable) + 1 # wait for exit to finish
self._width = width
self._enabled = enabled
self._file = sys.stdout if file is None else file |
732 | edbbf39b6591822bdbebe96c5bece1ed | swh:1:cnt:cca2b370a5b44b2ad301c6f86643ee7dd1ac864f;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=67-75/ | 8f1ba7f87211e41b75fe84d3ce1acae6aaf4e33e | conda-pack | analytics | conda_pack/_progress.py | progressbar::__exit__(self, type, value, traceback) | function | def __exit__(self, type, value, traceback):
if self._enabled:
self._running = False
self._timer.join()
if type is None: # Finished if no exception
self._ndone += 1
self._update_bar()
self._file.write('\n')
self._file.flush(... |
733 | 8f58a00f5ad791c8b878f6c0d68eff84 | swh:1:cnt:cca2b370a5b44b2ad301c6f86643ee7dd1ac864f;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=82-85/ | 8f1ba7f87211e41b75fe84d3ce1acae6aaf4e33e | conda-pack | analytics | conda_pack/_progress.py | progressbar::_timer_func(self) | function | def _timer_func(self):
while self._running:
self._update_bar()
time.sleep(0.1) |
734 | 4c48aa3447b60474631ebd54477ca1e1 | swh:1:cnt:cca2b370a5b44b2ad301c6f86643ee7dd1ac864f;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=87-99/ | 8f1ba7f87211e41b75fe84d3ce1acae6aaf4e33e | conda-pack | analytics | conda_pack/_progress.py | progressbar::_update_bar(self) | function | def _update_bar(self):
elapsed = default_timer() - self._start_time
frac = (self._ndone / self._ntotal) if self._ntotal else 1
bar = '#' * int(self._width * frac)
percent = int(100 * frac)
elapsed = format_time(elapsed)
msg = '\r[{0:<{1}}] | {2}% Completed | {3}'.format(b... |
735 | ff4cf26a6bd38cfa0ad9a1bbf210b35a | swh:1:cnt:cca2b370a5b44b2ad301c6f86643ee7dd1ac864f;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=25-99/ | 8f1ba7f87211e41b75fe84d3ce1acae6aaf4e33e | conda-pack | analytics | conda_pack/_progress.py | progressbar | type | class progressbar:
"""A simple progressbar for iterables.
Displays a progress bar showing progress through an iterable.
Parameters
----------
iterable : iterable
The object to iterate over.
width : int, optional
Width of the bar in characters.
enabled : bool, optional
... |
736 | beb9dc683f86ba0cc9b4644935bf5819 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=503-522/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render_pep440_old(pieces) | function | def render_pep440_old(pieces):
"""TAG[.postDISTANCE[.dev0]] .
The ".dev0" means dirty.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dirty"]:
rendered += ".post%d" % piec... |
737 | 2a98b1b4ef8667aecea796904eaf2aa5 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=525-542/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render_git_describe(pieces) | function | def render_git_describe(pieces):
"""TAG[-DISTANCE-gHEX][-dirty].
Like 'git describe --tags --dirty --always'.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix)
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"]:
rendered +=... |
738 | 7a09c1bbdab7dce68d8a007397150b3d | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=21-31/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | get_keywords() | function | def get_keywords():
"""Get the keywords needed to look up the version information."""
# these strings will be replaced by git during git-archive.
# setup.py/versioneer.py will grep for the variable names, so they must
# each be defined on a line of their own. _version.py will just call
# get_keyword... |
739 | a8b1e4e6da790ff890917a997da44fcf | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=38-49/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | get_config() | function | def get_config():
"""Create, populate and return the VersioneerConfig() object."""
# these strings are filled in when 'setup.py versioneer' creates
# _version.py
cfg = VersioneerConfig()
cfg.VCS = "git"
cfg.style = "pep440"
cfg.tag_prefix = ""
cfg.parentdir_prefix = "conda-pack-"
cfg... |
740 | 5fb3ee816ea5a6bc5866ccf3bc447c98 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=60-68/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | register_vcs_handler(vcs, method) | function | def register_vcs_handler(vcs, method): # decorator
"""Create decorator to mark a method as the handler of a VCS."""
def decorate(f):
"""Store f in HANDLERS[vcs][method]."""
if vcs not in HANDLERS:
HANDLERS[vcs] = {}
HANDLERS[vcs][method] = f
return f
return decor... |
741 | dc233f1d94b435348cffe9df52cb30ab | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=62-67/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | register_vcs_handler::decorate(f) | function | def decorate(f):
"""Store f in HANDLERS[vcs][method]."""
if vcs not in HANDLERS:
HANDLERS[vcs] = {}
HANDLERS[vcs][method] = f
return f |
742 | 8408b0dbf9fc95a9fc3727ee4fddeea1 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=447-471/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render_pep440_post(pieces) | function | def render_pep440_post(pieces):
"""TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[... |
743 | c1cf2311f683a43f62b1f168197c96ce | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=131-155/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | git_get_keywords(versionfile_abs) | function | def git_get_keywords(versionfile_abs):
"""Extract version information from the given file."""
# the code embedded in _version.py can just fetch the value of these
# keywords. When used from setup.py, we don't want to import _version.py,
# so we do it with a regexp instead. This function is not used from... |
744 | db354ab331a725b315310ae35cf97f38 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=223-348/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command) | function | def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
"""Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we... |
745 | 3956ae9708ad3e76ddb638ac3b6d9ae9 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=351-355/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | plus_or_dot(pieces) | function | def plus_or_dot(pieces):
"""Return a + if we don't already have one, else return a ."""
if "+" in pieces.get("closest-tag", ""):
return "."
return "+" |
746 | d1f4a5814ce826d605ffea4748d081dc | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=474-500/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render_pep440_post_branch(pieces) | function | def render_pep440_post_branch(pieces):
"""TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .
The ".dev0" means not master branch.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dir... |
747 | 2b28297d4526449d3ff20ed4ade4171a | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=71-103/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
env=None) | function | def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
env=None):
"""Call the given command(s)."""
assert isinstance(commands, list)
process = None
for command in commands:
try:
dispcmd = str([command] + args)
# remember shell=False, s... |
748 | c2b44fee6cc4ac342da4329f9fcb16d0 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=358-380/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render_pep440(pieces) | function | def render_pep440(pieces):
"""Build up version string, with post-release "local version identifier".
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
Exceptions:
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHE... |
749 | 6810be19af8f1d158eeddd0f70c6e15a | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=413-420/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | pep440_split_post(ver) | function | def pep440_split_post(ver):
"""Split pep440 version string at the post-release segment.
Returns the release segments before the post-release and the
post-release version number (or -1 if no post-release segment is present).
"""
vc = str.split(ver, ".post")
return vc[0], int(vc[1] or 0) if len(v... |
750 | 4da22e71a5d13e35bd24499a7b3cfdfb | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=545-562/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render_git_describe_long(pieces) | function | def render_git_describe_long(pieces):
"""TAG-DISTANCE-gHEX[-dirty].
Like 'git describe --tags --dirty --always -long'.
The distance/hash is unconditional.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix)
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
... |
751 | 1156585eb91f340bf99eba653da2d0e8 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=106-127/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | versions_from_parentdir(parentdir_prefix, root, verbose) | function | def versions_from_parentdir(parentdir_prefix, root, verbose):
"""Try to determine the version from the parent directory name.
Source tarballs conventionally unpack into a directory that includes both
the project name and a version string. We will also support searching up
two directory levels for an ap... |
752 | a1c01441088cf5b1f41028ea5f4a8744 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=159-219/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | git_versions_from_keywords(keywords, tag_prefix, verbose) | function | def git_versions_from_keywords(keywords, tag_prefix, verbose):
"""Get version information from git keywords."""
if "refnames" not in keywords:
raise NotThisMethod("Short version file found")
date = keywords.get("date")
if date is not None:
# Use only the last line. Previous lines may co... |
753 | f1a6d697a13cc8f4b1270d2cff5cb8d5 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=383-410/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render_pep440_branch(pieces) | function | def render_pep440_branch(pieces):
"""TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
The ".dev0" means not master branch. Note that .dev0 sorts backwards
(a feature branch will appear "older" than the master branch).
Exceptions:
1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty]
"""
if pieces["close... |
754 | 1d856fcb1f9eb53dcf3a18709a950438 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=423-444/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render_pep440_pre(pieces) | function | def render_pep440_pre(pieces):
"""TAG[.postN.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. 0.post0.devDISTANCE
"""
if pieces["closest-tag"]:
if pieces["distance"]:
# update the post release segment
tag_version, post_version = pep440_split_post(pieces["closest-ta... |
755 | 3fab8bc00e62824d90b08da661a02d93 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=565-598/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | render(pieces, style) | function | def render(pieces, style):
"""Render the given version pieces into the requested style."""
if pieces["error"]:
return {"version": "unknown",
"full-revisionid": pieces.get("long"),
"dirty": None,
"error": pieces["error"],
"date": None}
... |
756 | bd4708a7a4e01e2c52d46158bf2aff73 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=601-644/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | get_versions() | function | def get_versions():
"""Get version information or return default if unable to do so."""
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
# __file__, we can work backwards from there to the root. Some
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
#... |
757 | 3a85c812a50ed71318a31c12f61fde84 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=34-35/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | VersioneerConfig | type | class VersioneerConfig:
"""Container for Versioneer configuration parameters.""" |
758 | fc97020548280451e7ad0d7e16b2f023 | swh:1:cnt:583ed1dab22d02e92614376551f6dc6dd8e90ca7;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=52-53/ | b280593fe793543124c54baa98f9c5c40d091f91 | conda-pack | analytics | conda_pack/_version.py | NotThisMethod | type | class NotThisMethod(Exception):
"""Exception raised if a method is not valid for the current scenario.""" |
759 | 61d3ddff595660d0b355b177e3d03386 | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=59-76/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_cli_roundtrip(capsys, tmpdir) | function | def test_cli_roundtrip(capsys, tmpdir):
out_path = os.path.join(str(tmpdir), 'py37.tar')
with pytest.raises(SystemExit) as exc:
main(["-p", py37_path, "-o", out_path])
assert exc.value.code == 0
assert os.path.exists(out_path)
assert tarfile.is_tarfile(out_path)
out, err = capsys.rea... |
760 | edabe438551c81fb03bfac63e48c4dcb | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=27-35/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_version(capsys) | function | def test_version(capsys):
with pytest.raises(SystemExit) as exc:
main(["--version"])
assert exc.value.code == 0
out, err = capsys.readouterr()
assert not err
assert conda_pack.__version__ in out |
761 | 0eac324fd638745b8d6bf99a805a25fe | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=95-111/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_cli_exceptions(capsys) | function | def test_cli_exceptions(capsys):
with pytest.raises(SystemExit) as exc:
main(["-p", "not_a_real_path"])
assert exc.value.code == 1
out, err = capsys.readouterr()
assert "CondaPackError: Environment path" in err
with pytest.raises(SystemExit) as exc:
main(["-foo", "-bar"])
ass... |
762 | e757d4ddf8097d86ef7640fb5ceab4f3 | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=132-134/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_keyboard_interrupt::interrupt() | function | def interrupt():
time.sleep(0.2)
os.kill(os.getpid(), signal.SIGINT) |
763 | 06f5f6c264ed228ce582df4d89ccaf76 | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=16-24/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_help(capsys) | function | def test_help(capsys):
with pytest.raises(SystemExit) as exc:
main(["-h"])
assert exc.value.code == 0
out, err = capsys.readouterr()
assert not err
assert 'usage: conda-pack' in out |
764 | bdc83924f7bd1a8139ad0b774f543699 | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=38-56/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_parse_include_exclude() | function | def test_parse_include_exclude():
out = {}
def capture(**kwargs):
out.update(kwargs)
with pytest.raises(SystemExit) as exc:
main(["--exclude", "foo/*",
"--include", "*.py",
"--include", "*.pyx",
"--exclude", "foo/bar/*.pyx"],
pack=capt... |
765 | 55e0d2c9e184c2e769c970c9d5dd5c7d | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=41-42/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_parse_include_exclude::capture(**kwargs) | function | def capture(**kwargs):
out.update(kwargs) |
766 | 46c9b901cc675f1a54a32aca9841174e | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=79-92/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_quiet(capsys, tmpdir) | function | def test_quiet(capsys, tmpdir):
out_path = os.path.join(str(tmpdir), 'py37.tar')
with pytest.raises(SystemExit) as exc:
main(["-p", py37_path, "-o", out_path, "-q"])
assert exc.value.code == 0
assert os.path.exists(out_path)
assert tarfile.is_tarfile(out_path)
out, err = capsys.reado... |
767 | ebcc2d9e5900549402a0ac9c73ecdda3 | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=114-127/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_cli_warnings(capsys, tmpdir) | function | def test_cli_warnings(capsys, tmpdir):
out_path = os.path.join(str(tmpdir), 'py310.tar')
with pytest.raises(SystemExit) as exc:
main(["-p", py310_path, "-o", out_path])
assert exc.value.code == 0
assert os.path.exists(out_path)
assert tarfile.is_tarfile(out_path)
out, err = capsys.re... |
768 | aa7a634d39e6708582b537e596f8ce2d | swh:1:cnt:98e5738f02e2d17f7fbc1bda870aa4c10b5a2d5a;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=131-149/ | 65387d9829dd21ceba40cb9e2033e11e6d3b527b | conda-pack | analytics | conda_pack/tests/test_cli.py | test_keyboard_interrupt(capsys, tmpdir) | function | def test_keyboard_interrupt(capsys, tmpdir):
def interrupt():
time.sleep(0.2)
os.kill(os.getpid(), signal.SIGINT)
interrupter = Thread(target=interrupt)
out_path = os.path.join(str(tmpdir), 'py37.tar')
try:
with pytest.raises(SystemExit) as exc:
interrupter.start()
... |
769 | 4ffcd17f7750a99531651ef126f298cd | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=32-33/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | normpath(f) | function | def normpath(f):
return os.path.normcase(f).replace('\\', '/') |
770 | 0e11d9c1f33924bd834663d363b00ac8 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=64-77/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_from_prefix() | function | def test_from_prefix():
rel_env_dir = os.path.relpath(py37_path, os.getcwd())
env = CondaEnv.from_prefix(rel_env_dir)
assert len(env)
# relative path is normalized
assert os.path.normcase(env.prefix) == os.path.normcase(py37_path)
# Path is missing
with pytest.raises(CondaPackException):
... |
771 | 925492c5449a4c5a37b6f6e35f009331 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=105-111/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_errors_pip_overwrites() | function | def test_errors_pip_overwrites():
with pytest.raises(CondaPackException) as exc:
CondaEnv.from_prefix(py37_broken_path)
msg = str(exc.value)
assert "pip" in msg
assert "toolz" in msg |
772 | b8c4329e15510a5bd0e344b2d9670a9b | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=193-197/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_works_with_no_python() | function | def test_works_with_no_python():
# Collection doesn't require python
env = CondaEnv.from_prefix(nopython_path)
# non-empty
assert len(env) |
773 | 196fcff9aedac0353e18a7d6a1d307ef | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=455-490/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_pack(tmpdir, py37_env) | function | def test_pack(tmpdir, py37_env):
out_path = os.path.join(str(tmpdir), 'py37.tar')
exclude1 = "*.py"
exclude2 = "*.pyc"
include = os.path.join(SP_37, 'conda_pack_test_lib1', '*')
res = pack(prefix=py37_path,
output=out_path,
filters=[("exclude", exclude1),
... |
774 | 35aeabc4fc744aa3b1ab277b4ce630be | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=524-535/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_dest_prefix(tmpdir, py37_env) | function | def test_dest_prefix(tmpdir, py37_env):
out_path = os.path.join(str(tmpdir), 'py37.tar')
dest = r'c:\foo\bar\baz\biz' if on_win else '/foo/bar/baz/biz'
res = pack(prefix=py37_path,
dest_prefix=dest,
output=out_path)
assert res == out_path
assert os.path.exists(out_path... |
775 | c55c8e3ab7e9e39b5dff9854cf21ecc4 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=56-61/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_name_to_prefix() | function | def test_name_to_prefix():
# Smoketest on default name
name_to_prefix()
with pytest.raises(CondaPackException):
name_to_prefix("this_is_probably_not_a_real_env_name") |
776 | 63b2b98bfd5910fa54acc377973a2d47 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=80-91/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_missing_package_cache() | function | def test_missing_package_cache():
with pytest.warns(UserWarning) as record:
env = CondaEnv.from_prefix(py310_path)
assert len(env)
assert len(record) == 1
msg = str(record[0].message)
assert 'conda_pack_test_lib2' in msg
with pytest.raises(CondaPackException):
CondaEnv.from_pr... |
777 | 21ad503e605bda72411d709faccc9908 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=114-120/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_missing_files() | function | def test_missing_files():
with pytest.raises(CondaPackException) as exc:
CondaEnv.from_prefix(py37_missing_files_path)
msg = str(exc.value)
assert f"{os.sep}toolz{os.sep}__init__.py" in msg, msg
assert f"{os.sep}toolz{os.sep}_signatures.py" in msg, msg |
778 | 9dd83ca0de6e847e397db41a95e5bee4 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=200-213/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_include_exclude(py37_env) | function | def test_include_exclude(py37_env):
old_len = len(py37_env)
env2 = py37_env.exclude("*.pyc")
# No mutation
assert len(py37_env) == old_len
assert env2 is not py37_env
assert len(env2) < len(py37_env)
# Re-add the removed files, envs are equivalent
assert len(env2.include("*.pyc")) == le... |
779 | 0c64eb4449ba971fb93d39a0a844f547 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=493-521/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | _test_dest_prefix(src_prefix, dest_prefix, arcroot, out_path, format) | function | def _test_dest_prefix(src_prefix, dest_prefix, arcroot, out_path, format):
if on_win:
test_files = ['Scripts/conda-pack-test-lib1',
'Scripts/pytest.exe']
else:
test_files = ['bin/conda-pack-test-lib1',
'bin/pytest',
'bin/clear']
... |
780 | e42b652a42488cadffc4009928d6e955 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=538-573/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_parcel(tmpdir, py37_env) | function | def test_parcel(tmpdir, py37_env):
if on_win:
pytest.skip("Not parcel tests on Windows")
arcroot = 'py37-1234.56'
out_path = os.path.join(str(tmpdir), arcroot + '-el7.parcel')
pdir = os.getcwd()
try:
os.chdir(str(tmpdir))
res = pack(prefix=py37_path, format='parcel', parcel... |
781 | 2025dd10482ae0d2f5cc7f5948488c47 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=94-98/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_errors_editable_packages() | function | def test_errors_editable_packages():
with pytest.raises(CondaPackException) as exc:
CondaEnv.from_prefix(py37_editable_path)
assert "Editable packages found" in str(exc.value) |
782 | 59452274d267802ec844d43d162b7396 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=123-124/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_missing_files_ignored() | function | def test_missing_files_ignored():
CondaEnv.from_prefix(py37_missing_files_path, ignore_missing_files=True) |
783 | c8360edbb0c0678d6620e5442e83e792 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=40-41/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | py37_env() | function | def py37_env():
return CondaEnv.from_prefix(py37_path) |
784 | ba1303d8ed88453ecb9765f843f2d604 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=101-102/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_ignore_errors_editable_packages() | function | def test_ignore_errors_editable_packages():
CondaEnv.from_prefix(py37_editable_path, ignore_editable_packages=True) |
785 | af6304d4b7bd0533cd4377cf93e575ef | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=127-131/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_errors_conda_missing(bad_conda_exe) | function | def test_errors_conda_missing(bad_conda_exe):
with pytest.raises(CondaPackException) as exc:
CondaEnv.from_name('probably_fake_env')
assert 'Failed to determine path to environment' in str(exc.value) |
786 | 45e4154db445e5049cec670a56a62c9c | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=312-404/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_pack_with_conda(tmpdir, fix_dest) | function | def test_pack_with_conda(tmpdir, fix_dest):
env = CondaEnv.from_prefix(has_conda_path)
out_path = os.path.join(str(tmpdir), 'has_conda.tar')
extract_path = os.path.join(str(tmpdir), 'output')
env.pack(out_path, dest_prefix=extract_path if fix_dest else None)
os.mkdir(extract_path)
assert os.pa... |
787 | d534f79eb2ca5e9da7f2094a4e098992 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=157-160/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_file() | function | def test_file():
f = File('/root/path/to/foo/bar', 'foo/bar')
# smoketest repr
repr(f) |
788 | 5a403074ad806c781076b0004b0ec552 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=216-243/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_output_and_format(py37_env) | function | def test_output_and_format(py37_env):
output, format = py37_env._output_and_format()
assert output == 'py37.tar.gz'
assert format == 'tar.gz'
for format in ['tar.gz', 'tar.bz2', 'tar.xz', 'tar', 'zip', 'parcel']:
output = os.extsep.join([py37_env.name, format])
o, f = py37_env._output_... |
789 | ee2441a2879ee4d992faa62f0f227b09 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=45-53/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | bad_conda_exe(tmpdir_factory, monkeypatch) | function | def bad_conda_exe(tmpdir_factory, monkeypatch):
tmpdir = str(tmpdir_factory.mktemp('bin'))
fake_conda = os.path.join(tmpdir, 'conda.bat' if on_win else 'conda')
with open(fake_conda, 'w') as f:
f.write('ECHO Failed\r\nEXIT /B 1' if on_win else 'echo "Failed"\nexit 1')
os.chmod(fake_conda, os.sta... |
790 | 794963bcc0a4e30a9c79d33dfb1fd1ff | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=163-190/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_loaded_file_properties(py37_env) | function | def test_loaded_file_properties(py37_env):
lk = {normpath(f.target): f for f in py37_env}
# Pip installed entrypoint
exe_suffix = ".exe" if on_win else ""
fil = lk[f"{BIN_DIR_L}/pytest{exe_suffix}"]
assert not fil.is_conda
assert fil.file_mode == 'unknown'
assert fil.prefix_placeholder is N... |
791 | 9ab7a7ad6e1148af34e245ac50cb7053 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=246-308/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_roundtrip(tmpdir, py37_env) | function | def test_roundtrip(tmpdir, py37_env):
out_path = os.path.join(str(tmpdir), 'py37.tar')
py37_env.pack(out_path)
assert os.path.exists(out_path)
assert tarfile.is_tarfile(out_path)
with tarfile.open(out_path) as fil:
# Check all files are relative paths
for member in fil.getnames():
... |
792 | 6eb8a9da5da3b73193989e1a4b6a48b5 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=576-611/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_activate(tmpdir) | function | def test_activate(tmpdir):
out_path = os.path.join(str(tmpdir), 'activate_scripts.tar')
extract_path = str(tmpdir.join('env'))
env = CondaEnv.from_prefix(activate_scripts_path)
env.pack(out_path)
with tarfile.open(out_path) as fil:
fil.extractall(extract_path)
# Check that activate en... |
793 | 77b0b97cd0e7669229d5b7e82f447884 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=134-145/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_env_properties(py37_env) | function | def test_env_properties(py37_env):
assert py37_env.name == 'py37'
assert py37_env.prefix == py37_path
# Env has a length
assert len(py37_env) == len(py37_env.files)
# Env is iterable
assert len(list(py37_env)) == len(py37_env)
# Smoketest repr
assert 'CondaEnv<' in repr(py37_env) |
794 | 4473c621dd48270206fdf930f77a7f17 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=419-439/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_zip64(tmpdir) | function | def test_zip64(tmpdir):
# Create an environment that requires ZIP64 extensions, but doesn't use a
# lot of disk/RAM
source = os.path.join(str(tmpdir), 'source.txt')
with open(source, 'wb') as f:
f.write(b'0')
files = [File(source, target='foo%d' % i) for i in range(1 << 16)]
large_env =... |
795 | 899d7c4bb4596aaa760b51a3967e51ef | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=148-154/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_load_environment_ignores(py37_env) | function | def test_load_environment_ignores(py37_env):
lk = {normpath(f.target): f for f in py37_env}
for fname in ("conda", "conda.bat"):
assert f"{BIN_DIR_L}/{fname}" not in lk
for fname in ("activate", "activate.bat", "deactivate", "deactivate.bat"):
fpath = f"{BIN_DIR_L}/{fname}"
assert fp... |
796 | 813fd3b27e8905b08b6754193b926fa2 | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=407-416/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_pack_exceptions(py37_env) | function | def test_pack_exceptions(py37_env):
# Can't pass both prefix and name
with pytest.raises(CondaPackException):
pack(prefix=py37_path, name='py37')
# Unknown filter type
with pytest.raises(CondaPackException):
pack(prefix=py37_path,
filters=[("exclude", "*.py"),
... |
797 | e8a7306c374d6ba1413a06ff9315eefb | swh:1:cnt:edd8048d0ab4ddfeea199deee31eb4381e61b9eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=442-452/ | 2d6c17cfaf4b5b7d1a62c369cdf0124c62eaefe0 | conda-pack | analytics | conda_pack/tests/test_core.py | test_force(tmpdir, py37_env) | function | def test_force(tmpdir, py37_env):
already_exists = os.path.join(str(tmpdir), 'py37.tar')
with open(already_exists, 'wb'):
pass
# file already exists
with pytest.raises(CondaPackException):
py37_env.pack(output=already_exists)
py37_env.pack(output=already_exists, force=True)
ass... |
798 | afdeddc40b7d806d8da355f29e7f3dd6 | swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=90-97/ | 3d83aa21211e160c11af790c573fdd8255ec1819 | conda-pack | analytics | conda_pack/tests/test_formats.py | check::check_equal_contents(*paths) | function | def check_equal_contents(*paths):
with open(join(out_dir, *paths), 'rb') as path1:
packaged = path1.read()
with open(join(root, *paths), 'rb') as path2:
source = path2.read()
assert packaged == source |
799 | 64a2664f28dd613e357292270bbffae0 | swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=104-108/ | 3d83aa21211e160c11af790c573fdd8255ec1819 | conda-pack | analytics | conda_pack/tests/test_formats.py | check::checklink(path, sol) | function | def checklink(path, sol):
path = join(out_dir, "link_to_dir")
sol = join(out_dir, sol)
assert islink(path)
return join(out_dir, os.readlink(path)) == sol |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.