forked from jwilk/didjvu
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean docs; incorporate latest upstream changes
- Loading branch information
1 parent
344ac78
commit 5069b7e
Showing
45 changed files
with
250 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,3 @@ branch = true | |
[report] | ||
show_missing = true | ||
exclude_lines = # no coverage | ||
|
||
# vim:ft=dosini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,3 @@ jobs: | |
- name: check for Boost updates | ||
run: | ||
./private/check-new-boost-release | ||
|
||
# vim:ts=2 sts=2 sw=2 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,5 +192,3 @@ jobs: | |
run: | | ||
cd / | ||
man 1 didjvu | grep -A 10 -w DIDJVU | ||
# vim:ts=2 sts=2 sw=2 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Copyright © 2012-2019 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -45,5 +46,3 @@ clean: | |
rm -f *.tmp | ||
|
||
.error = GNU make is required | ||
|
||
# vim:ts=4 sts=4 sw=4 noet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2009-2021 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -16,5 +15,3 @@ | |
""" | ||
didjvu's private modules | ||
""" | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2009-2021 Jakub Wilk <[email protected]> | ||
# Copyright © 2009-2023 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -363,6 +362,7 @@ def dump_options(options, multi_page=False): | |
yield f'{layer_name}-subsample', layer.subsample | ||
|
||
|
||
__all__ = ['ArgumentParser', 'dump_options'] | ||
|
||
# vim:ts=4 sts=4 sw=4 et | ||
__all__ = [ | ||
'ArgumentParser', | ||
'dump_options' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2009-2021 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -21,6 +20,7 @@ | |
import logging | ||
import os | ||
import sys | ||
from typing import Any, Dict, Tuple | ||
|
||
from didjvu import cli | ||
from didjvu import djvu_support | ||
|
@@ -34,18 +34,18 @@ | |
from didjvu import xmp | ||
|
||
|
||
def setup_logging(): | ||
def setup_logging() -> Tuple[logging.Logger, logging.Logger]: | ||
logger = logging.getLogger('didjvu.main') | ||
ipc_logger = logging.getLogger('didjvu.ipc') | ||
logging.NOSY = (logging.INFO + logging.DEBUG) // 2 | ||
logging.NOSY = (logging.INFO + logging.DEBUG) // 2 # type: ignore[attr-defined] | ||
# noinspection PyUnresolvedReferences | ||
assert logging.INFO > logging.NOSY > logging.DEBUG | ||
assert logging.INFO > logging.NOSY > logging.DEBUG # type: ignore[attr-defined] | ||
|
||
def nosy(msg, *args, **kwargs): | ||
def nosy(msg: str, *args: Any, **kwargs: Any): | ||
# noinspection PyUnresolvedReferences | ||
logger.log(logging.NOSY, msg, *args, **kwargs) | ||
logger.log(logging.NOSY, msg, *args, **kwargs) # type: ignore[attr-defined] | ||
|
||
logger.nosy = nosy | ||
logger.nosy = nosy # type: ignore[attr-defined] | ||
# Main handler: | ||
handler = logging.StreamHandler() | ||
formatter = logging.Formatter('%(message)s') | ||
|
@@ -63,7 +63,7 @@ def nosy(msg, *args, **kwargs): | |
LOGGER, IPC_LOGGER = setup_logging() | ||
|
||
|
||
def error(message, *args, **kwargs): | ||
def error(message: str, *args: Any, **kwargs: Any) -> None: | ||
if args or kwargs: | ||
message = message.format(*args, **kwargs) | ||
print(f'didjvu: error: {message}', file=sys.stderr) | ||
|
@@ -452,14 +452,14 @@ def bundle_complex(self, options): | |
bytes_in = 0 | ||
pixels = [0] | ||
page_info = [] | ||
page_id_memo = {} | ||
page_id_memo: Dict[str, int] = {} | ||
for page_number, (image_filename, mask_filename) in enumerate(zip(options.input, options.masks)): | ||
page = utils.Namespace() | ||
page_info += [page] | ||
bytes_in += os.path.getsize(image_filename) | ||
page.page_id = templates.expand(options.page_id_template, image_filename, page_number, page_id_memo) | ||
try: | ||
djvu_support.validate_page_id(page.page_id) | ||
djvu_support.validate_page_id(page.page_id) # type: ignore[attr-defined] | ||
except ValueError as exception: | ||
error(exception) | ||
del page # quieten pyflakes | ||
|
@@ -472,11 +472,11 @@ def bundle_complex(self, options): | |
options.masks, | ||
itertools.repeat(pixels) | ||
) | ||
[pixels] = pixels | ||
[pixel_count] = pixels | ||
with temporary.directory() as minidjvu_out_dir: | ||
LOGGER.info('creating shared dictionaries') | ||
|
||
def chdir(): | ||
def chdir() -> None: | ||
os.chdir(minidjvu_out_dir) | ||
|
||
arguments = [ | ||
|
@@ -487,7 +487,7 @@ def chdir(): | |
if options.loss_level > 0: | ||
arguments += ['--aggression', str(options.loss_level)] | ||
assert len(page_info) > 1 # minidjvu won't create single-page indirect documents | ||
arguments += [page.sjbz_symlink for page in page_info] | ||
arguments += [page.sjbz_symlink for page in page_info] # type: ignore[attr-defined] | ||
index_filename = temporary.name(prefix='__index__.', suffix='.djvu', dir=minidjvu_out_dir) | ||
index_filename = os.path.basename(index_filename) # FIXME: Name conflicts are still possible! | ||
arguments += [index_filename] | ||
|
@@ -496,29 +496,27 @@ def chdir(): | |
component_filenames = [] | ||
for page_number, page in enumerate(page_info): | ||
if page_number % options.pages_per_dict == 0: | ||
iff_name = fs.replace_ext(page_info[page_number].page_id, 'iff') | ||
iff_name = fs.replace_ext(page_info[page_number].page_id, 'iff') # type: ignore[attr-defined] | ||
iff_name = os.path.join(minidjvu_out_dir, iff_name) | ||
component_filenames += [iff_name] | ||
sjbz_name = os.path.join(minidjvu_out_dir, page.page_id) | ||
sjbz_name = os.path.join(minidjvu_out_dir, page.page_id) # type: ignore[attr-defined] | ||
component_filenames += [sjbz_name] | ||
page.djvu['sjbz'] = sjbz_name | ||
page.djvu['incl'] = iff_name | ||
page.djvu = page.djvu.save() | ||
page.djvu_symlink = os.path.join(minidjvu_out_dir, page.page_id) | ||
os.unlink(page.djvu_symlink) | ||
os.symlink(page.djvu.name, page.djvu_symlink) | ||
page.djvu['sjbz'] = sjbz_name # type: ignore[attr-defined] | ||
page.djvu['incl'] = iff_name # type: ignore[attr-defined] | ||
page.djvu = page.djvu.save() # type: ignore[attr-defined] | ||
page.djvu_symlink = os.path.join(minidjvu_out_dir, page.page_id) # type: ignore[attr-defined] | ||
os.unlink(page.djvu_symlink) # type: ignore[attr-defined] | ||
os.symlink(page.djvu.name, page.djvu_symlink) # type: ignore[attr-defined] | ||
LOGGER.info('bundling') | ||
djvu_file = djvu_support.bundle_djvu(*component_filenames) | ||
try: | ||
bytes_out = fs.copy_file(djvu_file, output) | ||
finally: | ||
djvu_file.close() | ||
bits_per_pixel = 8.0 * bytes_out / pixels | ||
bits_per_pixel = 8.0 * bytes_out / pixel_count | ||
compression_info = format_compression_info(bytes_in, bytes_out, bits_per_pixel) | ||
# noinspection PyUnresolvedReferences | ||
LOGGER.nosy(compression_info) | ||
|
||
|
||
__all__ = ['Main'] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2009-2021 Jakub Wilk <[email protected]> | ||
# Copyright © 2009-2022 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -367,5 +366,3 @@ def validate_page_id(page_id): | |
'IW44_SLICES_DEFAULT', | ||
'CRCB', | ||
] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2010-2018 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -51,5 +50,3 @@ def check(filename): | |
'Djvu', | ||
'DjvuSingle', | ||
] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2009-2018 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -41,5 +40,3 @@ def replace_ext(filename, ext): | |
'copy_file', | ||
'replace_ext', | ||
] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2009-2021 Jakub Wilk <[email protected]> | ||
# Copyright © 2009-2022 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -250,5 +249,3 @@ def init(): | |
'to_pil_1bpp', | ||
'to_pil_rgb', | ||
] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2008-2021 Jakub Wilk <[email protected]> | ||
# Copyright © 2008-2022 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -162,5 +161,3 @@ def require(*commands): | |
'CalledProcessError', 'CalledProcessInterrupted', | ||
'Subprocess', 'PIPE', | ||
] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2010-2018 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -72,5 +71,3 @@ def expand(template, name, page, memo): | |
|
||
|
||
__all__ = ['expand'] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2009-2015 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -55,5 +54,3 @@ def directory(*args, **kwargs): | |
'hardlink', | ||
'name', | ||
] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2012-2019 Jakub Wilk <[email protected]> | ||
# Copyright © 2012-2024 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -17,8 +16,8 @@ | |
Timestamps. | ||
""" | ||
|
||
import time | ||
import datetime | ||
import time | ||
|
||
|
||
class Timestamp: | ||
|
@@ -69,6 +68,7 @@ def now(): | |
return Timestamp(time.time()) | ||
|
||
|
||
__all__ = ['Timestamp', 'now'] | ||
|
||
# vim:ts=4 sts=4 sw=4 et | ||
__all__ = [ | ||
'Timestamp', | ||
'now' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# encoding=UTF-8 | ||
|
||
# Copyright © 2011-2019 Jakub Wilk <[email protected]> | ||
# Copyright © 2022-2024 FriedrichFroebel | ||
# | ||
# This file is part of didjvu. | ||
# | ||
|
@@ -63,5 +62,3 @@ def __setattr__(self, name, value): | |
'Proxy', | ||
'enhance_import_error', | ||
] | ||
|
||
# vim:ts=4 sts=4 sw=4 et |
Oops, something went wrong.