Skip to content

Commit

Permalink
grammer and empty line - review
Browse files Browse the repository at this point in the history
  • Loading branch information
Paurikova2 committed Nov 13, 2024
1 parent 31235a4 commit ef27244
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/dspace/_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions src/pump/_license.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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)

Expand Down
16 changes: 11 additions & 5 deletions tools/license/fetch_licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'))
5 changes: 3 additions & 2 deletions tools/license/import_licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
_logger.info("End license import")

0 comments on commit ef27244

Please sign in to comment.