diff --git a/src/dspace/_rest.py b/src/dspace/_rest.py index 46aa9dd..db36b7d 100644 --- a/src/dspace/_rest.py +++ b/src/dspace/_rest.py @@ -244,8 +244,8 @@ def put_bitstreamregistry(self, data: dict): # ======= def fetch_licenses(self): - url ='core/clarinlicenses' - _logger.debug(f"Fatch [] using [{url}]") + url = 'core/clarinlicenses' + _logger.debug(f"Fetch [] using [{url}]") page = 0 licenses = [] while True: diff --git a/src/pump/_license.py b/src/pump/_license.py index 7e4c21b..6cc3bec 100644 --- a/src/pump/_license.py +++ b/src/pump/_license.py @@ -1,6 +1,5 @@ import os import logging - from pump._utils import read_json, time_method, serialize, deserialize, progress_bar, log_before_import, log_after_import _logger = logging.getLogger("pump.license") @@ -69,7 +68,7 @@ def imported_labels(self): def imported_licenses(self): return self._imported['licenses'] - def import_to(self, env, dspace, epersons = None): + def import_to(self, env, dspace, epersons=None): self._import_license_labels(env, dspace) self._import_license_defs(env, dspace, epersons) diff --git a/tools/license/fetch_licenses.py b/tools/license/fetch_licenses.py index f9255bb..f0ceb53 100644 --- a/tools/license/fetch_licenses.py +++ b/tools/license/fetch_licenses.py @@ -42,15 +42,18 @@ def filter_licenses(all_licenses, no_definition): if key in license and not any(arg in license[key] for arg in no_definition_set) ] + def write_data_to_file(data, output_path): """Write the filtered data to a JSON file.""" - os.makedirs(os.path.dirname(output_path), exist_ok=True) # Ensure output directory exists + os.makedirs(os.path.dirname(output_path), + exist_ok=True) # Ensure output directory exists with open(output_path, 'w', encoding='utf-8') as fout: json.dump(data, fout, indent=2) if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Get DSpace licenses that meet condition.") + parser = argparse.ArgumentParser( + description="Get DSpace licenses that meet condition.") parser.add_argument("--no_definition", type=str, nargs='+', required=True, help="String that cannot be part of the license definition") parser.add_argument('--output', type=str, @@ -100,9 +103,12 @@ def add_unique_label(label): _logger.info(f"Number of filtered licenses: {len(filtered_licenses)}") _logger.info(f"Number of filtered license labels: {len(filtered_license_labels)}") - _logger.info(f"Number of filtered license extended mapping: {len(filtered_ext_mapping)}") + _logger.info( + f"Number of filtered license extended mapping: {len(filtered_ext_mapping)}") # Write the filtered data to the specified output file - write_data_to_file([license.to_dict() for license in filtered_licenses], os.path.join(args.output, 'licenses.json')) - write_data_to_file([license.to_dict() for license in filtered_license_labels], os.path.join(args.output, 'labels.json')) + write_data_to_file([license.to_dict() for license in filtered_licenses], + os.path.join(args.output, 'licenses.json')) + write_data_to_file([license.to_dict() for license in filtered_license_labels], + os.path.join(args.output, 'labels.json')) write_data_to_file(filtered_ext_mapping, os.path.join(args.output, 'mapping.json')) diff --git a/tools/license/import_licenses.py b/tools/license/import_licenses.py index 1ca976e..02f903b 100644 --- a/tools/license/import_licenses.py +++ b/tools/license/import_licenses.py @@ -43,9 +43,10 @@ ) _logger.info("Loading license import") - licenses_imp = licenses(os.path.join(args.input, 'labels.json'), os.path.join(args.input, 'licenses.json'), os.path.join(args.input, 'mapping.json')) + licenses_imp = licenses(os.path.join(args.input, 'labels.json'), os.path.join( + args.input, 'licenses.json'), os.path.join(args.input, 'mapping.json')) # import licenses _logger.info("Start license import") licenses_imp.import_to(env, dspace_be) - _logger.info("End license import") \ No newline at end of file + _logger.info("End license import")