Skip to content

Commit

Permalink
clean docs; incorporate latest upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedrichFroebel committed Apr 13, 2024
1 parent 344ac78 commit 5069b7e
Show file tree
Hide file tree
Showing 45 changed files with 250 additions and 249 deletions.
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ branch = true
[report]
show_missing = true
exclude_lines = # no coverage

# vim:ft=dosini
9 changes: 2 additions & 7 deletions .github/dependabot.yml
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"
2 changes: 0 additions & 2 deletions .github/workflows/check-for-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ jobs:
- name: check for Boost updates
run:
./private/check-new-boost-release

# vim:ts=2 sts=2 sw=2 et
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,3 @@ jobs:
run: |
cd /
man 1 didjvu | grep -A 10 -w DIDJVU
# vim:ts=2 sts=2 sw=2 et
2 changes: 0 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ min-similarity-lines = 8
max-line-length = 140
expected-line-ending-format = LF

# vim:ft=dosini ts=4 sts=4 sw=4 et

3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright © 2012-2019 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -45,5 +46,3 @@ clean:
rm -f *.tmp

.error = GNU make is required

# vim:ts=4 sts=4 sw=4 noet
5 changes: 1 addition & 4 deletions didjvu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2009-2021 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand All @@ -16,5 +15,3 @@
"""
didjvu's private modules
"""

# vim:ts=4 sts=4 sw=4 et
18 changes: 15 additions & 3 deletions didjvu/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
# didjvu is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# didjvu is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.

from typing import Optional

def main(prog=None):

def main(prog: Optional[str] = None) -> None:
from didjvu.didjvu import Main
Main(prog=prog)

Expand Down
12 changes: 6 additions & 6 deletions didjvu/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2009-2021 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2009-2023 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -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'
]
48 changes: 23 additions & 25 deletions didjvu/didjvu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2009-2021 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand All @@ -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
Expand All @@ -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')
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 = [
Expand All @@ -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]
Expand All @@ -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
7 changes: 2 additions & 5 deletions didjvu/djvu_support.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2009-2021 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2009-2022 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -367,5 +366,3 @@ def validate_page_id(page_id):
'IW44_SLICES_DEFAULT',
'CRCB',
]

# vim:ts=4 sts=4 sw=4 et
5 changes: 1 addition & 4 deletions didjvu/filetype.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2010-2018 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -51,5 +50,3 @@ def check(filename):
'Djvu',
'DjvuSingle',
]

# vim:ts=4 sts=4 sw=4 et
5 changes: 1 addition & 4 deletions didjvu/fs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2009-2018 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -41,5 +40,3 @@ def replace_ext(filename, ext):
'copy_file',
'replace_ext',
]

# vim:ts=4 sts=4 sw=4 et
7 changes: 2 additions & 5 deletions didjvu/gamera_support.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2009-2021 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2009-2022 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -250,5 +249,3 @@ def init():
'to_pil_1bpp',
'to_pil_rgb',
]

# vim:ts=4 sts=4 sw=4 et
7 changes: 2 additions & 5 deletions didjvu/ipc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2008-2021 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2008-2022 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -162,5 +161,3 @@ def require(*commands):
'CalledProcessError', 'CalledProcessInterrupted',
'Subprocess', 'PIPE',
]

# vim:ts=4 sts=4 sw=4 et
5 changes: 1 addition & 4 deletions didjvu/templates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2010-2018 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -72,5 +71,3 @@ def expand(template, name, page, memo):


__all__ = ['expand']

# vim:ts=4 sts=4 sw=4 et
5 changes: 1 addition & 4 deletions didjvu/temporary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2009-2015 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -55,5 +54,3 @@ def directory(*args, **kwargs):
'hardlink',
'name',
]

# vim:ts=4 sts=4 sw=4 et
14 changes: 7 additions & 7 deletions didjvu/timestamp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2012-2019 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2012-2024 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand All @@ -17,8 +16,8 @@
Timestamps.
"""

import time
import datetime
import time


class Timestamp:
Expand Down Expand Up @@ -69,6 +68,7 @@ def now():
return Timestamp(time.time())


__all__ = ['Timestamp', 'now']

# vim:ts=4 sts=4 sw=4 et
__all__ = [
'Timestamp',
'now'
]
5 changes: 1 addition & 4 deletions didjvu/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding=UTF-8

# Copyright © 2011-2019 Jakub Wilk <jwilk@jwilk.net>
# Copyright © 2022-2024 FriedrichFroebel
#
# This file is part of didjvu.
#
Expand Down Expand Up @@ -63,5 +62,3 @@ def __setattr__(self, name, value):
'Proxy',
'enhance_import_error',
]

# vim:ts=4 sts=4 sw=4 et
Loading

0 comments on commit 5069b7e

Please sign in to comment.