Skip to content

Commit bc55366

Browse files
committed
fix: omit irrelevant objects, improve --config
1 parent 67652f4 commit bc55366

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed

src/reCBZ/__main__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,15 @@ def main():
300300
setattr(config, key, val)
301301

302302
if args.show_config:
303-
private = re.compile('^[A-Z]|\\<classmethod|^_')
304-
for key, val in config.__dict__.items():
305-
if not private.search(f'{key} = {val}'):
306-
print(f"{key} = {val}")
307-
303+
for section in config._cfg.items():
304+
print(f'\n{section[0].upper()}:')
305+
for key, val in section[1].items():
306+
modified = config.__dict__[key]
307+
print(f"{key} =".ljust(18),
308+
f"'{modified}'".ljust(8),
309+
f"(default '{val}')")
308310
defaults_path = Path.joinpath(reCBZ.MODULE_PATH, 'defaults.toml')
309-
print()
310-
print(f'configuration: {defaults_path}')
311+
print(f'\nConfig location: {defaults_path}')
311312
exit(0)
312313

313314
if args.show_profiles:

src/reCBZ/config.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717
_cfg = tomllib.loads(resources.read_text("reCBZ", "defaults.toml"))
1818

1919
overwrite:bool = _cfg["general"]["overwrite"]
20-
ignore_page_err:bool = _cfg["general"]["ignore"]
21-
force_write:bool = _cfg["general"]["force"]
22-
no_write:bool = _cfg["general"]["nowrite"]
20+
ignore_page_err:bool = _cfg["general"]["ignore_page_err"]
21+
force_write:bool = _cfg["general"]["force_write"]
22+
no_write:bool = _cfg["general"]["no_write"]
2323
loglevel:int = _cfg["general"]["loglevel"]
2424
processes:int = _cfg["general"]["processes"]
25-
samples_count:int = _cfg["general"]["samplecount"]
26-
archive_format:str = _cfg["archive"]["archiveformat"]
27-
compress_zip:int = _cfg["archive"]["compresszip"]
28-
right_to_left:bool = _cfg["archive"]["righttoleft"]
29-
img_format:str = _cfg["image"]["imageformat"]
30-
img_quality:int = _cfg["image"]["quality"]
31-
img_size:tuple = _cfg["image"]["size"]
32-
no_upscale:bool = _cfg["image"]["noupscale"]
33-
no_downscale:bool = _cfg["image"]["nodownscale"]
25+
samples_count:int = _cfg["general"]["samples_count"]
26+
archive_format:str = _cfg["archive"]["archive_format"]
27+
compress_zip:int = _cfg["archive"]["compress_zip"]
28+
right_to_left:bool = _cfg["archive"]["right_to_left"]
29+
img_format:str = _cfg["image"]["img_format"]
30+
img_quality:int = _cfg["image"]["img_quality"]
31+
img_size:tuple = _cfg["image"]["img_size"]
32+
no_upscale:bool = _cfg["image"]["no_upscale"]
33+
no_downscale:bool = _cfg["image"]["no_downscale"]
3434
grayscale:bool = _cfg["image"]["grayscale"]
35-
blacklisted_fmts:str = _cfg["image"]["blacklistedfmts"]
35+
blacklisted_fmts:str = _cfg["image"]["blacklisted_fmts"]
3636
ebook_profile = None
3737

3838

@@ -89,6 +89,6 @@ def allowed_page_formats() -> tuple:
8989
return valid_fmts
9090

9191

92-
preload_profile = _cfg["archive"]["ebookprofile"]
93-
if preload_profile != '':
94-
set_profile(preload_profile.upper())
92+
_preload_profile = _cfg["archive"]["ebook_profile"]
93+
if _preload_profile != '':
94+
set_profile(_preload_profile.upper())

src/reCBZ/defaults.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,43 @@
33
# whether to overwrite the original archive. dangerous
44
overwrite = false
55
# dry run. archive won't be saved, even if overwrite is used
6-
nowrite = false
6+
no_write = false
77
# try to skip files with read errors
8-
ignore = true
8+
ignore_page_err = true
99
# force write even if there are errors
10-
force = false
10+
force_write = false
1111
# level of logging: -1 = quiet. 0 = overlapping progress report. 1 = streaming
1212
# progress report. 2 = verbose messages. >2 = everything
1313
loglevel = 0
1414
# max number of processes to spawn. 0 will use available CPUs - 1.
1515
# 1 disables multiprocessing
1616
processes = 0
1717
# number of images to sample when comparing image formats
18-
samplecount = 5
18+
samples_count = 5
1919

2020
[archive]
2121
# default format to save archives as
22-
archiveformat = 'cbz'
22+
archive_format = 'cbz'
2323
# whether to further compress the zipfile after repacking
24-
compresszip = false
24+
compress_zip = false
2525
# default ereader profile to use, affects several other options
26-
ebookprofile = ''
26+
ebook_profile = ''
2727
# whether to write pages from right to left when using epub. rtl appears to be
2828
# unsupported on mobi
29-
righttoleft = false
29+
right_to_left = false
3030

3131
[image]
3232
# default format to convert images to. leave empty to preserve original
33-
imageformat = ''
33+
img_format = ''
3434
# compression quality for lossy images
35-
quality = 80
35+
img_quality = 80
3636
# new image width / height. set to 0,0 to preserve original dimensions
37-
size = [0,0]
37+
img_size = [0,0]
3838
# set to True to disable upscaling of images smaller than resolution
39-
noupscale = false
39+
no_upscale = false
4040
# set to True to disable downscaling of images larger than resolution
41-
nodownscale = false
41+
no_downscale = false
4242
# whether to convert images to grayscale
4343
grayscale = false
4444
# space separated list of image formats to always exclude from --compare
45-
blacklistedfmts = ''
45+
blacklisted_fmts = ''

0 commit comments

Comments
 (0)