Page MenuHomeSoftware Heritage

D5876.id21049.diff
No OneTemporary

D5876.id21049.diff

diff --git a/swh/__init__.py b/swh/__init__.py
--- a/swh/__init__.py
+++ b/swh/__init__.py
@@ -1,4 +1,4 @@
from pkgutil import extend_path
-from typing import List
+from typing import Iterable
-__path__: List[str] = extend_path(__path__, __name__)
+__path__: Iterable[str] = extend_path(__path__, __name__)
diff --git a/swh/model/cli.py b/swh/model/cli.py
--- a/swh/model/cli.py
+++ b/swh/model/cli.py
@@ -5,7 +5,7 @@
import os
import sys
-from typing import Dict, List, Optional
+from typing import Dict, Iterable, Optional
# WARNING: do not import unnecessary things here to keep cli startup time under
# control
@@ -75,7 +75,7 @@
)
-def model_of_dir(path: bytes, exclude_patterns: List[bytes] = None) -> Directory:
+def model_of_dir(path: bytes, exclude_patterns: Iterable[bytes] = None) -> Directory:
from swh.model.from_disk import accept_all_directories, ignore_directories_patterns
dir_filter = (
@@ -87,7 +87,7 @@
return Directory.from_disk(path=path, dir_filter=dir_filter)
-def swhid_of_dir(path: bytes, exclude_patterns: List[bytes] = None) -> CoreSWHID:
+def swhid_of_dir(path: bytes, exclude_patterns: Iterable[bytes] = None) -> CoreSWHID:
from swh.model.hashutil import hash_to_bytes
obj = model_of_dir(path, exclude_patterns)
@@ -150,7 +150,9 @@
)
-def identify_object(obj_type, follow_symlinks, exclude_patterns, obj) -> str:
+def identify_object(
+ obj_type: str, follow_symlinks: bool, exclude_patterns: Iterable[bytes], obj
+) -> str:
from urllib.parse import urlparse
if obj_type == "auto":
@@ -177,9 +179,7 @@
if obj_type == "content":
swhid = str(swhid_of_file(path))
elif obj_type == "directory":
- swhid = str(
- swhid_of_dir(path, [pattern.encode() for pattern in exclude_patterns])
- )
+ swhid = str(swhid_of_dir(path, exclude_patterns))
elif obj_type == "origin":
swhid = str(swhid_of_origin(obj))
elif obj_type == "snapshot":
@@ -275,6 +275,9 @@
from functools import partial
import logging
+ if exclude_patterns:
+ exclude_patterns = set(pattern.encode() for pattern in exclude_patterns)
+
if verify and len(objects) != 1:
raise click.BadParameter("verification requires a single object")

File Metadata

Mime Type
text/plain
Expires
Dec 21 2024, 5:37 PM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3232899

Event Timeline