Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/archive_extract.py
Show All 22 Lines | Args: | ||||
source (string): Optional source URL of the archive for adding to | source (string): Optional source URL of the archive for adding to | ||||
log messages. | log messages. | ||||
Returns: | Returns: | ||||
A context manager for a temporary directory that automatically | A context manager for a temporary directory that automatically | ||||
removes itself. See: help(tempfile.TemporaryDirectory) | removes itself. See: help(tempfile.TemporaryDirectory) | ||||
""" | """ | ||||
logstr = 'From %s - ' % source if log and source else '' | logstr = 'From %s - ' % source if log and source else '' | ||||
if dir and not os.path.exists(dir): | |||||
os.makedirs(dir, exist_ok=True) | |||||
archive_base = os.path.basename(archive) | archive_base = os.path.basename(archive) | ||||
if archive_base[0] == '.': | if archive_base[0] == '.': | ||||
package = '.' + archive_base.split('.')[1] | package = '.' + archive_base.split('.')[1] | ||||
else: | else: | ||||
package = archive_base.split('.')[0] | package = archive_base.split('.')[0] | ||||
tmpdir = tempfile.mkdtemp(dir=dir, prefix=prefix, suffix=suffix) | tmpdir = tempfile.mkdtemp(dir=dir, prefix=prefix, suffix=suffix) | ||||
repo_path = os.path.join(tmpdir, package) | repo_path = os.path.join(tmpdir, package) | ||||
Show All 13 Lines |