githubtakeout 0.1.17__tar.gz → 0.1.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {githubtakeout-0.1.17/src/githubtakeout.egg-info → githubtakeout-0.1.18}/PKG-INFO +1 -1
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/pyproject.toml +1 -1
- {githubtakeout-0.1.17 → githubtakeout-0.1.18/src/githubtakeout.egg-info}/PKG-INFO +1 -1
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/src/githubtakeout.py +19 -10
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/LICENSE +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/README.md +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/setup.cfg +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/src/githubtakeout.egg-info/SOURCES.txt +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/src/githubtakeout.egg-info/dependency_links.txt +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/src/githubtakeout.egg-info/entry_points.txt +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/src/githubtakeout.egg-info/requires.txt +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/src/githubtakeout.egg-info/top_level.txt +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/src/progress.py +0 -0
- {githubtakeout-0.1.17 → githubtakeout-0.1.18}/tests/test_githubtakeout.py +0 -0
|
@@ -51,27 +51,28 @@ def add_creds(url, username, token):
|
|
|
51
51
|
return new_url
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def archive(local_repo_dir, archive_format="zip",
|
|
54
|
+
def archive(local_repo_dir, archive_format="zip", archive_basename=None):
|
|
55
55
|
if archive_format not in ARCHIVE_FORMATS:
|
|
56
56
|
raise ValueError(f"{archive_format} is not a valid archive format")
|
|
57
57
|
if archive_format == "none":
|
|
58
58
|
return None
|
|
59
|
-
|
|
59
|
+
basename = os.path.basename(local_repo_dir)
|
|
60
60
|
extension = "tar.gz" if archive_format == "tar" else archive_format
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
if archive_basename is None:
|
|
62
|
+
archive_name = f"{basename}.{extension}"
|
|
63
|
+
else:
|
|
64
|
+
archive_name = f"{archive_basename}.{extension}"
|
|
64
65
|
parent_dir = os.path.dirname(local_repo_dir)
|
|
65
66
|
archive_path = os.path.join(parent_dir, archive_name)
|
|
66
67
|
logger.info(f"creating archive: {archive_path}")
|
|
67
68
|
if archive_format == "tar":
|
|
68
69
|
with tarfile.open(archive_path, "w:gz") as tar_archive:
|
|
69
|
-
tar_archive.add(local_repo_dir, arcname=
|
|
70
|
+
tar_archive.add(local_repo_dir, arcname=basename)
|
|
70
71
|
elif archive_format == "zip":
|
|
71
72
|
with zipfile.ZipFile(archive_path, "w", zipfile.ZIP_DEFLATED) as zip_archive:
|
|
72
73
|
repo_path = Path(local_repo_dir)
|
|
73
74
|
for entry in repo_path.rglob("*"):
|
|
74
|
-
path = os.path.join(
|
|
75
|
+
path = os.path.join(basename, entry.relative_to(repo_path))
|
|
75
76
|
zip_archive.write(entry, arcname=path)
|
|
76
77
|
return archive_path
|
|
77
78
|
|
|
@@ -124,7 +125,7 @@ def pull(local_repo_dir):
|
|
|
124
125
|
|
|
125
126
|
|
|
126
127
|
def get_and_archive_repo(
|
|
127
|
-
repo_url, local_repo_dir, archive_format, include_history, keep,
|
|
128
|
+
repo_url, local_repo_dir, archive_format, include_history, keep, description=None
|
|
128
129
|
):
|
|
129
130
|
def remove_readonly(func, path, _):
|
|
130
131
|
# This is necessary so rmtree() doesn't fail if there are any readonly
|
|
@@ -163,7 +164,15 @@ def get_and_archive_repo(
|
|
|
163
164
|
shutil.rmtree(git_dir, onexc=remove_readonly)
|
|
164
165
|
except FileNotFoundError:
|
|
165
166
|
pass
|
|
166
|
-
|
|
167
|
+
if description:
|
|
168
|
+
# clean unsafe chars and truncate description to create a useable file name
|
|
169
|
+
clean_name = re.sub(r"[/\\?%*:|\"<>\x7F\x00-\x1F]", "-", description)[:255]
|
|
170
|
+
archive_basename = f"gist - {clean_name}"
|
|
171
|
+
else:
|
|
172
|
+
archive_basename = None
|
|
173
|
+
archive_path = archive(
|
|
174
|
+
local_repo_dir, archive_format, archive_basename=archive_basename
|
|
175
|
+
)
|
|
167
176
|
if archive_path:
|
|
168
177
|
size = convert_size(os.path.getsize(archive_path))
|
|
169
178
|
logger.info(f"archive size: {size}")
|
|
@@ -285,7 +294,7 @@ def run(
|
|
|
285
294
|
archive_format,
|
|
286
295
|
include_history,
|
|
287
296
|
keep,
|
|
288
|
-
|
|
297
|
+
description=gist.description,
|
|
289
298
|
)
|
|
290
299
|
|
|
291
300
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{githubtakeout-0.1.17 → githubtakeout-0.1.18}/src/githubtakeout.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|