8000 pylint adjustments · homeylab/bookstack-file-exporter@82fae8c · GitHub
[go: up one dir, main page]

Skip to content

Commit 82fae8c

Browse files
committed
pylint adjustments
1 parent cd553b7 commit 82fae8c

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"features": {
88
"ghcr.io/devcontainers/features/python:1": {
99
"installTools": true,
10-
"version": "3.12.4"
10+
"version": "3.13.0"
1111
}
1212
},
1313
"customizations": {

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ build:
1919
python -m pip install --upgrade build
2020
python -m build
2121

22+
lint:
23+
pylint bookstack_file_exporter
24+
2225
upload_testpypi:
2326
python -m pip install --upgrade twine
2427
python -m twine upload --repository testpypi dist/*

bookstack_file_exporter/archiver/page_archiver.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Union, List, Dict
22
import logging
3+
# pylint: disable=import-error
4+
from requests.exceptions import HTTPError
35
from bookstack_file_exporter.exporter.node import Node
46
from bookstack_file_exporter.archiver import util as archiver_util
57
from bookstack_file_exporter.archiver.asset_archiver import AssetArchiver, ImageNode, AttachmentNode
@@ -76,12 +78,15 @@ def archive_pages(self, page_nodes: Dict[int, Node]):
7678
page.name, page_images)
7779
failed_attach = self.archive_page_assets("attachments", page.parent.file_path,
7880
page.name, page_attachments)
81+
# exclude from page_images
82+
# so it doesn't attempt to get modified in markdown file
7983
if failed_images:
80-
# exclude from page_images so it doesn't attempt to get modified in markdown file
8184
page_images = [img for img in page_images if img.id_ not in failed_images]
85+
# exclude from page_attachments
86+
# so it doesn't attempt to get modified in markdown file
8287
if failed_attach:
83-
# exclude from page_attachments so it doesn't attempt to get modified in markdown file
84-
page_attachments = [attach for attach in page_attachments if attach.id_ not in failed_attach]
88+
page_attachments = [attach for attach in page_attachments
89+
if attach.id_ not in failed_attach]
8590
for export_format in self.export_formats:
8691
page_data = self._get_page_data(page.id_, export_format)
8792
if page_images and export_format == 'markdown':
@@ -141,12 +146,14 @@ def archive_page_assets(self, asset_type: str, parent_path: str, page_name: str,
141146
for asset_node in asset_nodes:
142147
try:
143148
asset_data = self.asset_archiver.get_asset_bytes(asset_type, asset_node.url)
144-
except:
149+
except HTTPError:
145150
# probably unnecessary, but just in case
146151
if asset_node.id_ not in failed_assets:
147152
failed_assets[asset_node.id_] = 0
148-
# a 404 or other error occurred, skip this asset, already logged in http request exception
149-
log.error(f"Failed to get image or attachment data for asset located at: {asset_node.url} - skipping")
153+
# a 404 or other error occurred
154+
# skip this asset
155+
log.error("Failed to get image or attachment data " \
156+
"for asset located at: %s - skipping", asset_node.url)
150157
continue
151158
asset_path = f"{node_base_path}/{asset_node.get_relative_path(page_name)}"
152159
self.write_data(asset_path, asset_data)

bookstack_file_exporter/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ def exporter(args: argparse.Namespace):
5353
# clean up the .tgz archive since it is already uploaded
5454
archive.clean_up()
5555

56-
log.info(f"Created file archive: {archive.archive_dir}.tgz")
56+
log.info("Created file archive: %s.tgz", archive.archive_dir)
5757
log.info("Completed run")

0 commit comments

Comments
 (0)
0