From 2b7fd173204b4dfef8647bc9ef72d7978f5f8eea Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Wed, 8 Jan 2025 12:11:14 +0100 Subject: [PATCH] STY: auto formatting --- src/ruqad/crawler.py | 2 +- src/ruqad/kadi.py | 7 +++++-- src/ruqad/monitor.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ruqad/crawler.py b/src/ruqad/crawler.py index aa64335..ba459fa 100644 --- a/src/ruqad/crawler.py +++ b/src/ruqad/crawler.py @@ -87,6 +87,6 @@ def trigger_crawler(target_dir: str) -> tuple[bool, list[db.Entity]]: cfood_file_name=ruqad_crawler_settings.joinpath('cfood.yaml'), identifiables_definition_file=ruqad_crawler_settings.joinpath( 'identifiables.yaml'), - remove_prefix="/"+os.path.basename(target_dir)) + remove_prefix="/" + os.path.basename(target_dir)) return (True, ent_qc) diff --git a/src/ruqad/kadi.py b/src/ruqad/kadi.py index 539f00f..2e9f675 100644 --- a/src/ruqad/kadi.py +++ b/src/ruqad/kadi.py @@ -44,11 +44,12 @@ def _generate_pages(manager) -> dict: + str(response['code'])) n_pages = response["_pagination"]["total_pages"] for ii in range(n_pages): - query_params.update({"page": ii+1}) + query_params.update({"page": ii + 1}) yield manager.search.search_resources("record", **query_params).json() -def collect_records_created_after(manager: KadiManager, cut_off_date: datetime.datetime) -> list(int): +def collect_records_created_after(manager: KadiManager, + cut_off_date: datetime.datetime) -> list(int): """ Iterates page-wise over the responses of the Kadi API until records are reached that are older than the given cut_off_date. @@ -89,6 +90,7 @@ def download_eln_for(manager: KadiManager, rid: int, path: str) -> None: rec = manager.record(id=rid) rec.export(path=path, export_type='ro-crate') + class KadiManager(_KadiManager): """Fix KadiManager to respect context root in url.""" @@ -96,6 +98,7 @@ class KadiManager(_KadiManager): super().__init__(**kwargs) self.host = f'{kwargs["host"]}/api/v1' + def main(): with KadiManager(instance='demo') as manager: cut_off_date = datetime.fromisoformat( diff --git a/src/ruqad/monitor.py b/src/ruqad/monitor.py index d67dab3..9d549d0 100755 --- a/src/ruqad/monitor.py +++ b/src/ruqad/monitor.py @@ -42,6 +42,7 @@ KADIARGS = { SKIP_QUALITY_CHECK = os.getenv("SKIP_QUALITY_CHECK") is not None + def monitor(): """Continuously monitor the Kadi instance given in the environment variables. @@ -82,7 +83,7 @@ def monitor(): if os.path.exists(os.path.join(cdir, "artifacts.zip")): shutil.move(os.path.join(cdir, "artifacts.zip"), os.path.join(remote_dir_path, "report.zip")) - #else: + # else: # Path(os.path.join(remote_dir_path, "report.zip")).touch() shutil.move(os.path.join(cdir, "export.eln"), os.path.join(remote_dir_path, "export.eln")) -- GitLab