Skip to content

Commit

Permalink
code license failed to apply module cli params
Browse files Browse the repository at this point in the history
Signed-off-by: Parameswaran Selvam <[email protected]>
  • Loading branch information
Param-S committed Oct 11, 2024
1 parent b099d2d commit 2bb4cca
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 2bb4cca

Please sign in to comment.