From 15ccd9debab9d3fa7a72d0e4f36eb3df0ae076ea Mon Sep 17 00:00:00 2001 From: Benito Matischen Date: Thu, 4 Sep 2025 09:43:17 +0100 Subject: [PATCH 1/3] fix: Replace click.echo with logging.warning in exporter.py --- src/osfexport/exporter.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/osfexport/exporter.py b/src/osfexport/exporter.py index 87ee0f0..cb295cf 100644 --- a/src/osfexport/exporter.py +++ b/src/osfexport/exporter.py @@ -7,8 +7,11 @@ import importlib.metadata import time import random +import logging -import click +logging.basicConfig( + level=logging.WARNING, format='%(message)s' +) API_HOST_TEST = os.getenv('API_HOST_TEST', 'https://api.test.osf.io/v2') @@ -361,7 +364,7 @@ def paginate_json_result(start, action, fail_on_first=True, **kwargs): if fail_on_first and is_first_item or e.code == 429: raise e else: - click.echo("Error whilst parsing JSON page; continuing with other pages...") + logging.warning("Error whilst parsing JSON page; continuing with other pages...") # Stop if no next link found try: next_link = curr_page['links']['next'] @@ -721,8 +724,8 @@ def get_project_data(nodes, **kwargs): parent['data']['links']['html'] ) except (HTTPError, ValueError): - click.echo(f"Failed to load parent for {project_data['metadata']['title']}") - click.echo("Try to give a PAT beforehand using the --pat flag.", "\n") + logging.warning(f"Failed to load parent for {project_data['metadata']['title']}") + logging.warning("Try to give a PAT beforehand using the --pat flag.", "\n") # Projects specified by ID to export also count as start nodes for PDFs # This will be the first node in list of root nodes @@ -752,10 +755,10 @@ def get_children(json_page, **kwargs): if isinstance(e, HTTPError): if e.code == 429: raise e - click.echo(f"A project failed to export: {e.code}") + logging.warning(f"A project failed to export: {e.code}") else: - click.echo("A project failed to export: Unexpected API response.") - click.echo("Continuing with exporting other projects...") + logging.warning("A project failed to export: Unexpected API response.") + logging.warning("Continuing with exporting other projects...") return projects, root_nodes From 034a50ea2fc52fe876d6d2b1a8b44599c54de38f Mon Sep 17 00:00:00 2001 From: Benito Matischen Date: Thu, 4 Sep 2025 09:44:38 +0100 Subject: [PATCH 2/3] chore: Bump version to 0.2.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d0b895c..b7731af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "osfexport" -version = "0.2.1" +version = "0.2.2" authors = [ { name="Benito Matischen", email="benito.matischen@manchester.ac.uk" }, { name="Ramiro Bravo", email="ramiro.bravo@manchester.ac.uk" }, From df023c1383cfa36ce61b26cbbffac24ed5f00127 Mon Sep 17 00:00:00 2001 From: Benito Matischen Date: Thu, 4 Sep 2025 09:45:29 +0100 Subject: [PATCH 3/3] chore: Fix linting errors --- src/osfexport/exporter.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/osfexport/exporter.py b/src/osfexport/exporter.py index cb295cf..967d395 100644 --- a/src/osfexport/exporter.py +++ b/src/osfexport/exporter.py @@ -724,8 +724,13 @@ def get_project_data(nodes, **kwargs): parent['data']['links']['html'] ) except (HTTPError, ValueError): - logging.warning(f"Failed to load parent for {project_data['metadata']['title']}") - logging.warning("Try to give a PAT beforehand using the --pat flag.", "\n") + logging.warning( + f"Failed to load parent for {project_data['metadata']['title']}" + ) + logging.warning( + "Try to give a PAT beforehand using the --pat flag.", + "\n" + ) # Projects specified by ID to export also count as start nodes for PDFs # This will be the first node in list of root nodes