Skip to content

Commit 943e30b

Browse files
committed
moved COMPRESSION_EXTS out of loop
1 parent 8e6167b commit 943e30b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

databusclient/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ def create_distributions_from_metadata(metadata: List[Dict[str, Union[str, int]]
225225
"""
226226
distributions = []
227227
counter = 0
228+
229+
# Known compression extensions
230+
COMPRESSION_EXTS = {"gz", "bz2", "xz", "zip", "7z", "tar", "lz", "zst"}
231+
228232
for entry in metadata:
229233
# Validate required keys
230234
required_keys = ["filename", "checksum", "size", "url"]
@@ -242,8 +246,6 @@ def create_distributions_from_metadata(metadata: List[Dict[str, Union[str, int]]
242246
if not isinstance(checksum, str) or len(checksum) != 64 or not all(
243247
c in '0123456789abcdefABCDEF' for c in checksum):
244248
raise ValueError(f"Invalid checksum for {filename}")
245-
# Known compression extensions
246-
COMPRESSION_EXTS = {"gz", "bz2", "xz", "zip", "7z", "tar", "lz", "zst"}
247249

248250
parts = filename.split(".")
249251
if len(parts) == 1:
@@ -254,7 +256,6 @@ def create_distributions_from_metadata(metadata: List[Dict[str, Union[str, int]]
254256
compression = "none"
255257
else:
256258
# Check if last part is a known compression
257-
258259
if parts[-1] in COMPRESSION_EXTS:
259260
compression = parts[-1]
260261
# Handle compound extensions like .tar.gz

0 commit comments

Comments
 (0)