Skip to content

Commit 6ccf6b1

Browse files
committed
Replace --skip-system-scope with --skip-os-packages
1 parent a10ab01 commit 6ccf6b1

18 files changed

+75
-79
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pip install -r requirements.txt
1515

1616
# Run specific detectors for testing
1717
python3 -m dependency_resolver docker <container_name>
18-
python3 -m dependency_resolver host --skip-system-scope --skip-hash-generation
18+
python3 -m dependency_resolver host --skip-os-packages --skip-hash-generation
1919

2020
# Execute linting and formatting
2121
pre-commit run --files $(git diff --name-only --diff-filter=ACMR HEAD)

dependency_resolver/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def resolve_host_dependencies(
1212
working_dir: Optional[str] = None,
1313
debug: bool = False,
14-
skip_system_scope: bool = False,
14+
skip_os_packages: bool = False,
1515
venv_path: Optional[str] = None,
1616
pretty_print: bool = False,
1717
) -> str:
@@ -21,15 +21,15 @@ def resolve_host_dependencies(
2121
Args:
2222
working_dir: Working directory to analyze (defaults to current directory)
2323
debug: Enable debug output
24-
skip_system_scope: Skip system-scope package managers
24+
skip_os_packages: Skip OS package managers (dpkg, apk)
2525
venv_path: Explicit virtual environment path for pip detector
2626
pretty_print: Format JSON output with indentation
2727
2828
Returns:
2929
JSON string containing all discovered dependencies
3030
"""
3131
executor = HostExecutor(debug=debug)
32-
orchestrator = Orchestrator(debug=debug, skip_system_scope=skip_system_scope, venv_path=venv_path)
32+
orchestrator = Orchestrator(debug=debug, skip_os_packages=skip_os_packages, venv_path=venv_path)
3333
dependencies = orchestrator.resolve_dependencies(executor, working_dir)
3434
formatter = OutputFormatter(debug=debug)
3535
return formatter.format_json(dependencies, pretty_print=pretty_print)
@@ -39,7 +39,7 @@ def resolve_docker_dependencies(
3939
container_identifier: str,
4040
working_dir: Optional[str] = None,
4141
debug: bool = False,
42-
skip_system_scope: bool = False,
42+
skip_os_packages: bool = False,
4343
venv_path: Optional[str] = None,
4444
only_container_info: bool = False,
4545
pretty_print: bool = False,
@@ -51,7 +51,7 @@ def resolve_docker_dependencies(
5151
container_identifier: Container ID or name
5252
working_dir: Working directory to analyze within the container
5353
debug: Enable debug output
54-
skip_system_scope: Skip system-scope package managers
54+
skip_os_packages: Skip OS package managers (dpkg, apk)
5555
venv_path: Explicit virtual environment path for pip detector
5656
only_container_info: Only analyze container metadata (skip dependency detection)
5757
pretty_print: Format JSON output with indentation
@@ -60,7 +60,7 @@ def resolve_docker_dependencies(
6060
JSON string containing all discovered dependencies
6161
"""
6262
executor = DockerExecutor(container_identifier, debug=debug)
63-
orchestrator = Orchestrator(debug=debug, skip_system_scope=skip_system_scope, venv_path=venv_path)
63+
orchestrator = Orchestrator(debug=debug, skip_os_packages=skip_os_packages, venv_path=venv_path)
6464
dependencies = orchestrator.resolve_dependencies(executor, working_dir, only_container_info)
6565
formatter = OutputFormatter(debug=debug)
6666
return formatter.format_json(dependencies, pretty_print=pretty_print)
@@ -70,7 +70,7 @@ def resolve_docker_dependencies_as_dict(
7070
container_identifier: str,
7171
working_dir: Optional[str] = None,
7272
debug: bool = False,
73-
skip_system_scope: bool = False,
73+
skip_os_packages: bool = False,
7474
venv_path: Optional[str] = None,
7575
only_container_info: bool = False,
7676
) -> dict[str, Any]:
@@ -84,7 +84,7 @@ def resolve_docker_dependencies_as_dict(
8484
container_identifier: Container ID or name
8585
working_dir: Working directory to analyze within the container
8686
debug: Enable debug output
87-
skip_system_scope: Skip system-scope package managers
87+
skip_os_packages: Skip OS package managers (dpkg, apk)
8888
venv_path: Explicit virtual environment path for pip detector
8989
only_container_info: Only analyze container metadata (skip dependency detection)
9090
@@ -99,7 +99,7 @@ def resolve_docker_dependencies_as_dict(
9999
raise ValueError("Container identifier is required")
100100

101101
executor = DockerExecutor(container_identifier, debug=debug)
102-
orchestrator = Orchestrator(debug=debug, skip_system_scope=skip_system_scope, venv_path=venv_path)
102+
orchestrator = Orchestrator(debug=debug, skip_os_packages=skip_os_packages, venv_path=venv_path)
103103
return orchestrator.resolve_dependencies(executor, working_dir, only_container_info)
104104

105105

@@ -108,7 +108,7 @@ def resolve_dependencies_as_dict(
108108
environment_identifier: Optional[str] = None,
109109
working_dir: Optional[str] = None,
110110
debug: bool = False,
111-
skip_system_scope: bool = False,
111+
skip_os_packages: bool = False,
112112
venv_path: Optional[str] = None,
113113
only_container_info: bool = False,
114114
) -> dict[str, Any]:
@@ -120,7 +120,7 @@ def resolve_dependencies_as_dict(
120120
environment_identifier: Environment identifier (required for docker)
121121
working_dir: Working directory to analyze
122122
debug: Enable debug output
123-
skip_system_scope: Skip system-scope package managers
123+
skip_os_packages: Skip OS package managers (dpkg, apk)
124124
venv_path: Explicit virtual environment path for pip detector
125125
only_container_info: Only analyze container metadata (for docker environments)
126126
@@ -137,7 +137,7 @@ def resolve_dependencies_as_dict(
137137
else:
138138
raise ValueError(f"Unsupported environment type: {environment_type}")
139139

140-
orchestrator = Orchestrator(debug=debug, skip_system_scope=skip_system_scope, venv_path=venv_path)
140+
orchestrator = Orchestrator(debug=debug, skip_os_packages=skip_os_packages, venv_path=venv_path)
141141
return orchestrator.resolve_dependencies(executor, working_dir, only_container_info)
142142

143143

dependency_resolver/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def parse_arguments() -> argparse.Namespace:
3535
%(prog)s --working-dir /tmp/repo # Set working directory on target environment
3636
%(prog)s --venv-path ~/.virtualenvs/myproject # Use specific virtual environment for pip
3737
%(prog)s --debug # Enable debug output
38-
%(prog)s --skip-system-scope # Skip system scope package managers
38+
%(prog)s --skip-os-packages # Skip OS package managers (dpkg, apk)
3939
%(prog)s --skip-hash-collection # Skip hash collection for improved performance
4040
%(prog)s --select-detectors "pip,dpkg" # Use only pip and dpkg detectors
4141
""",
@@ -63,9 +63,9 @@ def parse_arguments() -> argparse.Namespace:
6363
parser.add_argument("--debug", action="store_true", help="Print debug statements")
6464

6565
parser.add_argument(
66-
"--skip-system-scope",
66+
"--skip-os-packages",
6767
action="store_true",
68-
help="Skip system scope package managers (system packages or globally installed Python packages)",
68+
help="Skip OS package managers (dpkg, apk) - language package managers like pip/npm will still run",
6969
)
7070

7171
parser.add_argument(
@@ -137,7 +137,7 @@ def main() -> None:
137137
executor = create_executor(args.environment_type, args.environment_identifier, debug=args.debug)
138138
orchestrator = Orchestrator(
139139
debug=args.debug,
140-
skip_system_scope=args.skip_system_scope,
140+
skip_os_packages=args.skip_os_packages,
141141
venv_path=args.venv_path,
142142
skip_hash_collection=args.skip_hash_collection,
143143
selected_detectors=args.select_detectors,

dependency_resolver/core/interfaces.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ def get_dependencies(
4949
raise NotImplementedError
5050

5151
@abstractmethod
52-
def has_system_scope(self, executor: EnvironmentExecutor, working_dir: Optional[str] = None) -> bool:
53-
"""Check if this detector operates at system scope for the given environment.
52+
def is_os_package_manager(self) -> bool:
53+
"""Check if this detector manages OS-level packages (like dpkg, apk).
5454
55-
Returns True if the detector would return scope: "system" in get_dependencies().
56-
This allows efficient scope checking without the overhead of dependency extraction.
55+
Returns True for OS package managers that install system packages.
56+
Returns False for language package managers (pip, npm, maven) and other detectors.
5757
"""
5858
raise NotImplementedError

dependency_resolver/core/orchestrator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class Orchestrator:
1414
def __init__(
1515
self,
1616
debug: bool = False,
17-
skip_system_scope: bool = False,
17+
skip_os_packages: bool = False,
1818
venv_path: str | None = None,
1919
skip_hash_collection: bool = False,
2020
selected_detectors: str | None = None,
2121
):
2222
self.debug = debug
23-
self.skip_system_scope = skip_system_scope
23+
self.skip_os_packages = skip_os_packages
2424
self.skip_hash_collection = skip_hash_collection
2525

2626
# Create all detector instances
@@ -77,10 +77,10 @@ def resolve_dependencies(
7777

7878
try:
7979
if detector.is_usable(executor, working_dir):
80-
# Check if detector has system scope and skip if requested
81-
if self.skip_system_scope and detector.has_system_scope(executor, working_dir):
80+
# Check if detector is OS package manager and skip if requested
81+
if self.skip_os_packages and detector.is_os_package_manager():
8282
if self.debug:
83-
print(f"Skipping {detector_name} (system scope, --skip-system-scope enabled)")
83+
print(f"Skipping {detector_name} (OS package manager, --skip-os-packages enabled)")
8484
continue
8585

8686
if self.debug:

dependency_resolver/detectors/apk_detector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ def get_dependencies(
7575

7676
return {"scope": "system", "dependencies": dependencies}
7777

78-
def has_system_scope(self, executor: EnvironmentExecutor, working_dir: Optional[str] = None) -> bool:
79-
"""APK always has system scope (system packages)."""
78+
def is_os_package_manager(self) -> bool:
79+
"""APK manages OS-level packages."""
8080
return True

dependency_resolver/detectors/docker_info_detector.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ def get_dependencies(
4242

4343
return result
4444

45-
def has_system_scope(self, executor: EnvironmentExecutor, working_dir: Optional[str] = None) -> bool:
46-
"""Docker container info has container scope, not system scope."""
47-
_ = executor # Unused parameter, required by interface
48-
_ = working_dir # Unused parameter, required by interface
45+
def is_os_package_manager(self) -> bool:
46+
"""Docker info detector is not an OS package manager."""
4947
return False

dependency_resolver/detectors/dpkg_detector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,6 @@ def _combine_md5_hashes(self, md5_hashes: list[str]) -> str | None:
224224
content = "\n".join(sorted(md5_hashes))
225225
return hashlib.sha256(content.encode()).hexdigest()
226226

227-
def has_system_scope(self, executor: EnvironmentExecutor, working_dir: Optional[str] = None) -> bool:
228-
"""DPKG always has system scope (system packages)."""
227+
def is_os_package_manager(self) -> bool:
228+
"""DPKG manages OS-level packages."""
229229
return True

dependency_resolver/detectors/maven_detector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def get_dependencies(
5252
result["dependencies"] = dependencies
5353
return result
5454

55-
def has_system_scope(self, executor: EnvironmentExecutor, working_dir: Optional[str] = None) -> bool:
56-
"""Maven is always project scope."""
55+
def is_os_package_manager(self) -> bool:
56+
"""Maven is a language package manager, not an OS package manager."""
5757
return False
5858

5959
def _maven_available(self, executor: EnvironmentExecutor, working_dir: Optional[str] = None) -> bool:

dependency_resolver/detectors/npm_detector.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ def _generate_location_hash(self, executor: EnvironmentExecutor, location: str)
152152
print(f"ERROR: location: {location}")
153153
return ""
154154

155-
def has_system_scope(self, executor: EnvironmentExecutor, working_dir: Optional[str] = None) -> bool:
156-
"""NPM has system scope when no local package.json or node_modules exists."""
157-
location = self._get_npm_location(executor, working_dir)
158-
return self._is_system_location(location)
155+
def is_os_package_manager(self) -> bool:
156+
"""NPM is a language package manager, not an OS package manager."""
157+
return False

0 commit comments

Comments
 (0)