Skip to content

Commit

Permalink
Use Python's logger (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggravlingen authored Mar 9, 2024
1 parent f2c870e commit 61bcbe1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions pyesef/download/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import requests

from pyesef.log import LOGGER

from ..const import PATH_ARCHIVES

BASE_URL = "https://filings.xbrl.org/"
Expand Down Expand Up @@ -77,7 +79,7 @@ def _download_package(filing: Filing) -> None:
# Create download path if it does not exist
Path(download_path).mkdir(parents=True, exist_ok=True)

print(f"Downloading {url}") # noqa: T201
LOGGER.info(f"Downloading {url}")

req = requests.get(url, stream=True, timeout=30)
write_location = os.path.join(download_path, filing.file_name)
Expand Down Expand Up @@ -119,10 +121,10 @@ def download_packages() -> None:

data_list = _cleanup_package_dict(identifier_map=identifier_map)

print(f"{len(data_list)} items found") # noqa: T201
LOGGER.info(f"{len(data_list)} items found")

for idx, item in enumerate(data_list):
if idx % 10 == 0:
print(f"Parsing {idx}/{len(data_list)}") # noqa: T201
LOGGER.info(f"Parsing {idx}/{len(data_list)}")

_download_package(item)
1 change: 0 additions & 1 deletion pyesef/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"root": {
"handlers": [
"json_file",
"console",
],
"level": "INFO",
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ disable = [
"too-many-return-statements",
"too-few-public-methods",
"too-many-locals",
# It's easier to use f-string than lazy % formatting
"logging-fstring-interpolation",
]

[tool.pylint.REPORTS]
Expand Down

0 comments on commit 61bcbe1

Please sign in to comment.