diff --git a/src/pds/registrysweepers/repairkit/__init__.py b/src/pds/registrysweepers/repairkit/__init__.py index fc6ec6f..9ce094d 100644 --- a/src/pds/registrysweepers/repairkit/__init__.py +++ b/src/pds/registrysweepers/repairkit/__init__.py @@ -9,6 +9,7 @@ from . import allarrays from pds.registrysweepers.utils import Host +from pds.registrysweepers.utils import configure_logging from pds.registrysweepers.utils import query_registry_db import logging @@ -37,17 +38,18 @@ def function_name (document:{}, fieldname:str)->{} ''' REPAIR_TOOLS = { -re.compile('^ops:Data_File_Info/').match:[allarrays.repair], -re.compile('^ops:Label_File_Info/').match:[allarrays.repair], +re.compile('^ops:Data_File_Info/').match: [allarrays.repair], +re.compile('^ops:Label_File_Info/').match: [allarrays.repair], } log = logging.getLogger(__name__) + def run(base_url:str, username:str, password:str, - verify_host_certs:bool=True, - log_filepath:Union[str,None]=None, + verify_host_certs:bool = True, + log_filepath:Union[str,None] = None, log_level:int=logging.INFO): configure_logging(filepath=log_filepath, log_level=log_level) log.info("starting CLI processing") @@ -56,10 +58,10 @@ def run(base_url:str, for document in query_registry_db(host, query, {}): repairs = {} for fieldname,data in document.items(): - for regex,funcs in REPAIR_TOOLS: + for regex,funcs in REPAIR_TOOLS.items(): if regex(filename): repairs.update(func(document, fieldname) for func in funcs) if repairs: - log.info (f'Writing repairs to document: {id}') - write_update_docs (host, {id,repairs}) + log.info(f'Writing repairs to document: {id}') + write_update_docs(host, {id:repairs}) return diff --git a/src/pds/registrysweepers/repairkit/allarrays.py b/src/pds/registrysweepers/repairkit/allarrays.py index 700f6f4..cddc26a 100644 --- a/src/pds/registrysweepers/repairkit/allarrays.py +++ b/src/pds/registrysweepers/repairkit/allarrays.py @@ -3,5 +3,5 @@ def repair (document:{}, fieldname:str)->bool: if isinstance (document[fieldname], str): log.info (f'found string for {fieldname} where it should be an array') - return {fieldname:[document[fieldname]} + return {fieldname:[document[fieldname]]} return {}