From 2bb4cca298895e5c6505d8e1a71e49ee352bc7b4 Mon Sep 17 00:00:00 2001 From: Parameswaran Selvam Date: Thu, 10 Oct 2024 11:51:58 -0700 Subject: [PATCH] code license failed to apply module cli params Signed-off-by: Parameswaran Selvam --- .../python/src/license_select_transform.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/transforms/code/license_select/python/src/license_select_transform.py b/transforms/code/license_select/python/src/license_select_transform.py index dc4ad2b72..a43d399a3 100644 --- a/transforms/code/license_select/python/src/license_select_transform.py +++ b/transforms/code/license_select/python/src/license_select_transform.py @@ -48,7 +48,6 @@ LICENSE_COLUMN_DEFAULT = "license" LICENSES_KEY = "licenses" - def _get_supported_licenses(license_file: str, data_access: DataAccess) -> list[str]: logger.info(f"Getting supported licenses from file {license_file}") licenses_list = None @@ -120,7 +119,6 @@ def transform(self, table: pa.Table, file_name: str = None) -> tuple[list[pa.Tab new_table = self.transformer.transform(table) return [new_table], {} - class LicenseSelectTransformConfiguration(TransformConfiguration): def __init__(self): super().__init__(name="license_select", transform_class=LicenseSelectTransform) @@ -159,18 +157,25 @@ def add_input_params(self, parser: ArgumentParser) -> None: self.daf.add_input_params(parser) def apply_input_params(self, args: Namespace) -> bool: + if not self.daf.apply_input_params(args): + return False + captured = CLIArgumentProvider.capture_parameters(args, CLI_PREFIX, False) - data_access = self.daf.create_data_access() - deny = captured.get(DENY_LICENSES_KEY, False) - license_list_file = captured.get(LICENSES_FILE_KEY) + license_column_name = captured.get(LICENSE_COLUMN_NAME_KEY) + allow_licenses = captured.get(ALLOW_NO_LICENSE_KEY) + deny_licenses = captured.get(DENY_LICENSES_KEY, False) + licenses_file = captured.get(LICENSES_FILE_KEY) + # Read licenses from allow-list or deny-list - licenses = _get_supported_licenses(license_list_file, data_access) + data_access = self.daf.create_data_access() + licenses = _get_supported_licenses(licenses_file, data_access) + self.params = { LICENSE_SELECT_PARAMS: { - LICENSE_COLUMN_NAME_KEY: captured.get(LICENSE_COLUMN_NAME_KEY), - ALLOW_NO_LICENSE_KEY: captured.get(ALLOW_NO_LICENSE_KEY), + LICENSE_COLUMN_NAME_KEY: license_column_name, + ALLOW_NO_LICENSE_KEY: allow_licenses, + DENY_LICENSES_KEY: deny_licenses, LICENSES_KEY: licenses, - DENY_LICENSES_KEY: deny, } } return True