Skip to content

Commit

Permalink
minor updates for running
Browse files Browse the repository at this point in the history
  • Loading branch information
Al Niessner authored and Al Niessner committed Aug 1, 2023
1 parent 6d6652b commit 64119bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pds/registrysweepers/repairkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ def run(base_url:str,
host = Host(password, base_url, username, verify_host_certs)
query = {"match_all":{}}
for document in query_registry_db(host, query, {}):
id = document['_id']
src = document['_source']
repairs = {}
for fieldname,data in document.items():
log.debug (f'working on document: {id}')
for fieldname,data in src.items():
for regex,funcs in REPAIR_TOOLS.items():
if regex(filename):
repairs.update(func(document, fieldname) for func in funcs)
if regex(fieldname):
for func in funcs: repairs.update(func(src, fieldname))
if repairs:
log.info(f'Writing repairs to document: {id}')
write_update_docs(host, {id:repairs})
Expand Down
6 changes: 6 additions & 0 deletions src/pds/registrysweepers/repairkit/allarrays.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
'''change single strings to array of strings'''

import logging

log = logging.getLogger(__name__)


def repair (document:{}, fieldname:str)->bool:
log.debug(f'checking {fieldname}')
if isinstance (document[fieldname], str):
log.info (f'found string for {fieldname} where it should be an array')
return {fieldname:[document[fieldname]]}
Expand Down

0 comments on commit 64119bd

Please sign in to comment.