Skip to content

Commit a823db3

Browse files
committed
Revert configurable directory
1 parent 1b612fd commit a823db3

File tree

5 files changed

+14
-40
lines changed

5 files changed

+14
-40
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ options:
4242
--dry-run Verify any installation targets but do not run the package manager command
4343
--log-level LEVEL Desired logging level (default: WARNING, options: DEBUG, INFO, WARNING, ERROR)
4444
--executable PATH Python or npm executable to use for running commands (default: environmentally determined)
45-
--verifiers PATH Directory from which installation target verifiers should be sourced (default: scfw/verifiers)
46-
--loggers PATH Directory from which loggers should be sourced (default: scfw/loggers)
4745
```
4846

4947
### Compatibility

scfw/cli.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,6 @@ def _cli() -> ArgumentParser:
5757
help="Python or npm executable to use for running commands (default: environmentally determined)"
5858
)
5959

60-
parser.add_argument(
61-
"--verifiers",
62-
type=str,
63-
default=None,
64-
metavar="PATH",
65-
help="Directory from which installation target verifiers should be sourced (default: scfw/verifiers)"
66-
)
67-
68-
parser.add_argument(
69-
"--loggers",
70-
type=str,
71-
default=None,
72-
metavar="PATH",
73-
help="Directory from which loggers should be sourced (default: scfw/loggers)"
74-
)
75-
7660
return parser
7761

7862

scfw/firewall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def run_firewall() -> int:
3333
return 0
3434

3535
log.setLevel(args.log_level)
36-
logs = loggers.get_firewall_loggers(args.loggers)
36+
logs = loggers.get_firewall_loggers()
3737

3838
log.info(f"Starting supply-chain firewall on {time.asctime(time.localtime())}")
3939
log.info(f"Command: '{' '.join(args.command)}'")
@@ -44,7 +44,7 @@ def run_firewall() -> int:
4444
log.info(f"Command would install: [{', '.join(map(str, targets))}]")
4545

4646
if targets:
47-
verifiers = verifs.get_install_target_verifiers(args.verifiers)
47+
verifiers = verifs.get_install_target_verifiers()
4848
log.info(
4949
f"Using installation target verifiers: [{', '.join(v.name() for v in verifiers)}]"
5050
)

scfw/loggers/__init__.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,33 @@ def load_logger() -> FirewallLogger
1515
```
1616
1717
This `load_logger` function should return an instance of the custom logger
18-
for the firewall's use. The module may then be placed in the directory configured
19-
on the command line (in this directory otherwise) from which loggers should be
20-
sourced for runtime import.
18+
for the firewall's use. The module may then be placed in the same directory
19+
as this source file for runtime import. Make sure to reinstall the package
20+
after doing so.
2121
"""
2222

2323
import importlib
2424
import logging
2525
import os
2626
import pkgutil
27-
from typing import Optional
2827

2928
from scfw.logger import FirewallLogger
3029

3130
_log = logging.getLogger(__name__)
3231

3332

34-
def get_firewall_loggers(source: Optional[str]) -> list[FirewallLogger]:
33+
def get_firewall_loggers() -> list[FirewallLogger]:
3534
"""
3635
Return the currently discoverable set of client loggers.
3736
38-
Args:
39-
source: An optional direction from which to source loggers.
40-
4137
Returns:
4238
A `list` of the discovered `FirewallLogger`s.
4339
"""
4440
loggers = []
4541

46-
for _, module, _ in pkgutil.iter_modules([source if source else os.path.dirname(__file__)]):
42+
for _, module, _ in pkgutil.iter_modules([os.path.dirname(__file__)]):
4743
try:
48-
logger = importlib.import_module(module).load_logger()
44+
logger = importlib.import_module(f".{module}", package=__name__).load_logger()
4945
loggers.append(logger)
5046
except ModuleNotFoundError:
5147
_log.warning(f"Failed to load module {module} while collecting loggers")

scfw/verifiers/__init__.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,33 @@ def load_verifier() -> InstallTargetVerifier
1717
```
1818
1919
This `load_verifier` function should return an instance of the custom verifier
20-
for the firewall's use. The module may then be placed in the directory configured
21-
on the command line (in this directory otherwise) from which verifiers should be
22-
sourced for runtime import.
20+
for the firewall's use. The module may then be placed in the same directory
21+
as this source file for runtime import. Make sure to reinstall the package
22+
after doing so.
2323
"""
2424

2525
import importlib
2626
import logging
2727
import os
2828
import pkgutil
29-
from typing import Optional
3029

3130
from scfw.verifier import InstallTargetVerifier
3231

3332
_log = logging.getLogger(__name__)
3433

3534

36-
def get_install_target_verifiers(source: Optional[str]) -> list[InstallTargetVerifier]:
35+
def get_install_target_verifiers() -> list[InstallTargetVerifier]:
3736
"""
3837
Return the currently discoverable set of installation target verifiers.
3938
40-
Args:
41-
source: An optional directory from which to source verifiers.
42-
4339
Returns:
4440
A list of the discovered installation target verifiers.
4541
"""
4642
verifiers = []
4743

48-
for _, module, _ in pkgutil.iter_modules([source if source else os.path.dirname(__file__)]):
44+
for _, module, _ in pkgutil.iter_modules([os.path.dirname(__file__)]):
4945
try:
50-
verifier = importlib.import_module(module).load_verifier()
46+
verifier = importlib.import_module(f".{module}", package=__name__).load_verifier()
5147
verifiers.append(verifier)
5248
except ModuleNotFoundError:
5349
_log.warning(f"Failed to load module {module} while collecting installation target verifiers")

0 commit comments

Comments
 (0)