Skip to content

Commit 7e41131

Browse files
committed
CU-869azeyvz: Avoid creating implicit medcat-scripts folder.
Instead, add everything directly to the folder specified
1 parent ec0c064 commit 7e41131

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

medcat-v2/medcat/utils/download_scripts.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,18 @@ def fetch_scripts(destination: str | Path = ".") -> Path:
7979
# Extract only medcat-scripts/ from the archive
8080
with zipfile.ZipFile(zip_path) as zf:
8181
for m in zf.namelist():
82-
if f"/{SCRIPTS_PATH}" in m:
83-
# skip repo-hash prefix
84-
target = dest / Path(*Path(m).parts[1:])
85-
if m.endswith("/"):
86-
target.mkdir(parents=True, exist_ok=True)
87-
else:
88-
with open(target, "wb") as f:
89-
f.write(zf.read(m))
90-
91-
logger.info("Scripts extracted to: %s", dest / SCRIPTS_PATH)
92-
return dest / SCRIPTS_PATH
82+
if f"/{SCRIPTS_PATH}" not in m:
83+
continue
84+
# skip repo-hash prefix
85+
target = dest / Path(*Path(m).parts[2:])
86+
if m.endswith("/"):
87+
target.mkdir(parents=True, exist_ok=True)
88+
else:
89+
with open(target, "wb") as f:
90+
f.write(zf.read(m))
91+
92+
logger.info("Scripts extracted to: %s", dest)
93+
return dest
9394

9495

9596
def main(destination: str = ".",

0 commit comments

Comments
 (0)