Skip to content

Commit

Permalink
Small tweak to allow lookup_checker to use a specified policy dir whe…
Browse files Browse the repository at this point in the history
…n called from code.
  • Loading branch information
netsettler committed Sep 29, 2023
1 parent ab9ee54 commit 20e6153
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions dcicutils/license_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,12 @@ def find_checker(cls, checker_name: str) -> Optional[Type[LicenseChecker]]:
return cls.REGISTRY.get(checker_name, None)

@classmethod
def lookup_checker(cls, checker_name: str, autoload: bool = False) -> Type[LicenseChecker]:
def lookup_checker(cls, checker_name: str, autoload: bool = False,
policy_dir: Optional[str] = None) -> Type[LicenseChecker]:
result: Optional[Type[LicenseChecker]] = cls.find_checker(checker_name)
if result is None:
if autoload:
policy_dir = LicenseOptions.POLICY_DIR or POLICY_DIR
if autoload or policy_dir:
policy_dir = policy_dir or LicenseOptions.POLICY_DIR or POLICY_DIR
PRINT(f"Looking for custom policy {checker_name} in {policy_dir} ...")
result = find_or_create_license_class(policy_name=checker_name,
policy_dir=policy_dir)
Expand Down
4 changes: 2 additions & 2 deletions dcicutils/scripts/run_license_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def main():
parser.add_argument("--debug", '-q', default=False, action="store_true",
help="Requests additional debugging output.")
parser.add_argument("--conda-prefix", "--conda_prefix", "--cp", default=LicenseOptions.CONDA_PREFIX,
help=(f"Overrides the CONDA_PREFIX (default {LicenseOptions.CONDA_PREFIX!r})."))
help=f"Overrides the CONDA_PREFIX (default {LicenseOptions.CONDA_PREFIX!r}).")
parser.add_argument("--policy-dir", "--policy_dir", "--pd", default=LicenseOptions.POLICY_DIR,
help=(f"Specifies a custom policy directory (default {LicenseOptions.POLICY_DIR!r})."))
help=f"Specifies a custom policy directory (default {LicenseOptions.POLICY_DIR!r}).")

args = parser.parse_args()

Expand Down

0 comments on commit 20e6153

Please sign in to comment.