Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove print statements #28

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WordPress Site Extractor
WPextract
Copyright 2022-2024 The University of Sheffield

Portions of this code are derived from WPJsonScraper, which is available under the MIT license. For details, see src/wpextract/download/LICENSE.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ select = [
"PT",
"B",
"UP",
"RUF"
"RUF",
"T20"
]

ignore = [
Expand Down
1 change: 0 additions & 1 deletion src/wpextract/cli/_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def download(
OUT_JSON is the directory to output the downloaded JSON to. It must be an existing empty directory or a non-existent directory which will be created.
"""
setup_logging(verbose, log)
print(verbose)

types_to_dl = set(dl_types) - set(skip_types)

Expand Down
1 change: 0 additions & 1 deletion src/wpextract/download/requestsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ def do_request(self, method, url, data=None, stream=False):
logging.error(f"Connection reset by {url}")
raise ConnectionReset from e
else:
print(e)
raise e
except requests.Timeout as e:
logging.error(f"Request timed out fetching {url}")
Expand Down
3 changes: 2 additions & 1 deletion src/wpextract/download/wpapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import logging
import math
from json.decoder import JSONDecodeError
from urllib.parse import urlencode
Expand Down Expand Up @@ -156,7 +157,7 @@ def crawl_pages(
) and "X-WP-Total" in req.headers:
total_entries = int(req.headers["X-WP-Total"])
total_pages = int(req.headers["X-WP-TotalPages"])
print("Total number of entries: %d" % total_entries)
logging.info("Total number of entries: %d" % total_entries)
if start is not None and total_entries < start:
start = total_entries - 1
except HTTPErrorInvalidPage:
Expand Down
10 changes: 5 additions & 5 deletions src/wpextract/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ def download_media_files(self, session: RequestSession, dest: Path):
session: the request session to use
dest: destination directory for media
"""
print("Pulling media URLs")
logging.info("Pulling media URLs")
media, slugs = self.scanner.get_media_urls("all", cache=True)

if len(media) == 0:
logging.warning("No media found corresponding to the criteria")
return
print(f"{len(media)} media URLs found")
logging.info(f"{len(media)} media URLs found")

number_dl = Exporter.download_media(session, media, dest)
print(f"Downloaded {number_dl} media files")
logging.info(f"Downloaded {number_dl} media files")

def _get_fetch_or_list_type(self, obj_type, plural=False):
"""Returns a dict containing all necessary metadata about the obj_type to list and fetch data.
Expand Down Expand Up @@ -117,7 +117,7 @@ def _get_fetch_or_list_type(self, obj_type, plural=False):

def _list_obj(self, obj_type, start=None, limit=None, cache=True):
prop = self._get_fetch_or_list_type(obj_type, plural=True)
print(prop["obj_name"] + " details")
logging.info(f"Downloading {prop['obj_name']}")

try:
kwargs = {}
Expand All @@ -138,7 +138,7 @@ def _list_obj(self, obj_type, start=None, limit=None, cache=True):
logging.error("The API does not support WP V2")
except OSError as e:
logging.error(f"Could not open {e.filename} for writing")
print()
logging.info(f"Completed downloading {prop['obj_name']}")

@staticmethod
def export_decorator(
Expand Down