Skip to content

Commit

Permalink
fix: omit irrelevant objects, improve --config
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonv committed Dec 13, 2022
1 parent 67652f4 commit bc55366
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
15 changes: 8 additions & 7 deletions src/reCBZ/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,15 @@ def main():
setattr(config, key, val)

if args.show_config:
private = re.compile('^[A-Z]|\\<classmethod|^_')
for key, val in config.__dict__.items():
if not private.search(f'{key} = {val}'):
print(f"{key} = {val}")

for section in config._cfg.items():
print(f'\n{section[0].upper()}:')
for key, val in section[1].items():
modified = config.__dict__[key]
print(f"{key} =".ljust(18),
f"'{modified}'".ljust(8),
f"(default '{val}')")
defaults_path = Path.joinpath(reCBZ.MODULE_PATH, 'defaults.toml')
print()
print(f'configuration: {defaults_path}')
print(f'\nConfig location: {defaults_path}')
exit(0)

if args.show_profiles:
Expand Down
32 changes: 16 additions & 16 deletions src/reCBZ/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
_cfg = tomllib.loads(resources.read_text("reCBZ", "defaults.toml"))

overwrite:bool = _cfg["general"]["overwrite"]
ignore_page_err:bool = _cfg["general"]["ignore"]
force_write:bool = _cfg["general"]["force"]
no_write:bool = _cfg["general"]["nowrite"]
ignore_page_err:bool = _cfg["general"]["ignore_page_err"]
force_write:bool = _cfg["general"]["force_write"]
no_write:bool = _cfg["general"]["no_write"]
loglevel:int = _cfg["general"]["loglevel"]
processes:int = _cfg["general"]["processes"]
samples_count:int = _cfg["general"]["samplecount"]
archive_format:str = _cfg["archive"]["archiveformat"]
compress_zip:int = _cfg["archive"]["compresszip"]
right_to_left:bool = _cfg["archive"]["righttoleft"]
img_format:str = _cfg["image"]["imageformat"]
img_quality:int = _cfg["image"]["quality"]
img_size:tuple = _cfg["image"]["size"]
no_upscale:bool = _cfg["image"]["noupscale"]
no_downscale:bool = _cfg["image"]["nodownscale"]
samples_count:int = _cfg["general"]["samples_count"]
archive_format:str = _cfg["archive"]["archive_format"]
compress_zip:int = _cfg["archive"]["compress_zip"]
right_to_left:bool = _cfg["archive"]["right_to_left"]
img_format:str = _cfg["image"]["img_format"]
img_quality:int = _cfg["image"]["img_quality"]
img_size:tuple = _cfg["image"]["img_size"]
no_upscale:bool = _cfg["image"]["no_upscale"]
no_downscale:bool = _cfg["image"]["no_downscale"]
grayscale:bool = _cfg["image"]["grayscale"]
blacklisted_fmts:str = _cfg["image"]["blacklistedfmts"]
blacklisted_fmts:str = _cfg["image"]["blacklisted_fmts"]
ebook_profile = None


Expand Down Expand Up @@ -89,6 +89,6 @@ def allowed_page_formats() -> tuple:
return valid_fmts


preload_profile = _cfg["archive"]["ebookprofile"]
if preload_profile != '':
set_profile(preload_profile.upper())
_preload_profile = _cfg["archive"]["ebook_profile"]
if _preload_profile != '':
set_profile(_preload_profile.upper())
28 changes: 14 additions & 14 deletions src/reCBZ/defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@
# whether to overwrite the original archive. dangerous
overwrite = false
# dry run. archive won't be saved, even if overwrite is used
nowrite = false
no_write = false
# try to skip files with read errors
ignore = true
ignore_page_err = true
# force write even if there are errors
force = false
force_write = false
# level of logging: -1 = quiet. 0 = overlapping progress report. 1 = streaming
# progress report. 2 = verbose messages. >2 = everything
loglevel = 0
# max number of processes to spawn. 0 will use available CPUs - 1.
# 1 disables multiprocessing
processes = 0
# number of images to sample when comparing image formats
samplecount = 5
samples_count = 5

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

[image]
# default format to convert images to. leave empty to preserve original
imageformat = ''
img_format = ''
# compression quality for lossy images
quality = 80
img_quality = 80
# new image width / height. set to 0,0 to preserve original dimensions
size = [0,0]
img_size = [0,0]
# set to True to disable upscaling of images smaller than resolution
noupscale = false
no_upscale = false
# set to True to disable downscaling of images larger than resolution
nodownscale = false
no_downscale = false
# whether to convert images to grayscale
grayscale = false
# space separated list of image formats to always exclude from --compare
blacklistedfmts = ''
blacklisted_fmts = ''

0 comments on commit bc55366

Please sign in to comment.