Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ docker-decrypt: docker-build
"powerdownload && powerdecrypt"

docker-release: docker-build
docker run\
-v $(CURDIR):/var/workdir\
-e GH_TOKEN=$(GH_TOKEN)\
$(IMAGE_NAME)\
"baw release --no_test --no_linter"
@if git describe --exact-match --tags HEAD >/dev/null 2>&1; then\
echo "Current commit is already tagged. Skipping release.";\
else \
docker run\
-v $(CURDIR):/var/workdir\
-e GH_TOKEN=$(GH_TOKEN)\
$(IMAGE)\
"baw release --no_test --no_linter";\
fi
28 changes: 4 additions & 24 deletions letty/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import collections
import concurrent
import itertools
import math
import os
import sys

Expand Down Expand Up @@ -99,10 +98,10 @@ def strategy(
lines: int = 1,
boxes: int = 1,
):
boxes_flow = ranges(0.5, 1.0, boxes)
char_margin = ranges(0.5, 20.0, chars)
line_margin = ranges(0.01, 5.0, lines)
word_margin = ranges(1.5, 5.0, words)
boxes_flow = utilo.ranged_exp(0.5, 1.0, boxes)
char_margin = utilo.ranged_exp(0.5, 20.0, chars)
line_margin = utilo.ranged_exp(0.01, 5.0, lines)
word_margin = utilo.ranged_exp(1.5, 5.0, words)
result = []
for char, word, box, line, in itertools.product(
char_margin,
Expand All @@ -117,22 +116,3 @@ def strategy(
'line_margin': line,
})
return result


# TODO: REPLACE WITH utilo CODE
def ranges(mini: float, maxi: float, steps: int = 15):
"""Compute parameter.

>>> utilo.roundme(ranges(0.1, 100, steps=10))
[0.1, 0.12, 0.18, 0.34, 0.76, 1.92, 5.06, 13.61, 36.84, 99.99]
>>> utilo.roundme(ranges(0.1, 20, steps=5))
[0.1, 0.73, 2.43, 7.06, 19.64]
"""
func = math.exp
maxed = func(steps - 1) / (maxi - mini)
result = []
for index in range(steps):
value = mini + (math.exp(index) - 1) / maxed
value = utilo.roundme(value, digits=5) # pylint:disable=R0204
result.append(value)
return result
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ authors = [
]
dependencies = [
"pdfminer.six>=20260107,<20270000",
"pillow>=12.2.0,<13.0.0",
"utilo>=2.105.0,<3.0.0",
"pillow>=12.3.0,<13.0.0",
"utilo>=2.109.0,<3.0.0",
"configos>=1.0.4,<2.0.0",
"iamraw>=4.91.0,<5.0.0",
"iamraw>=4.91.7,<5.0.0",
"protoerror>=3.20.2,<4.0.0",
"ughost>=1.0.1,<2.0.0",
"pdflog>=1.0.2,<2.0.0",
Expand All @@ -33,10 +33,10 @@ content-type = "text/markdown"

[project.optional-dependencies]
dev = [
"hoverpower>=1.1.0,<2.0.0",
"jamer>=1.0.1,<2.0.0",
"utilotest>=1.0.2,<2.0.0",
"gennex>=1.0.1,<2.0.0",
"hoverpower>=1.5.1,<2.0.0",
"jamer>=1.0.2,<2.0.0",
"utilotest>=1.0.4,<2.0.0",
"gennex>=1.0.3,<2.0.0",
"yamlfix>=1.19.1,<2.0.0",
]
table = [
Expand Down
3 changes: 1 addition & 2 deletions rawmaker/cli_automate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import sys

import utilo
import utilotest

DESCRIPTION = """\
Collect pdf files of defined folders and use them to run rawmaker.
Expand Down Expand Up @@ -60,7 +59,7 @@ def run(inpath: str, outpath: str, cores: int = 1):
_, name = os.path.split(item)
# use quotation marks to encapsulate file path white spaces
item = f'"{item}"' if ' ' in str(item) else item
name = utilotest.simple(name) # TODO: REPLACE WITH utilo CODE
name = utilo.simple(name)
out = os.path.join(outpath, name)
cmd = f'rawmaker -i {item} -o {out} -j4'
cmds.append(cmd)
Expand Down
5 changes: 2 additions & 3 deletions rawmaker/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ def read(path: str, password: str = None, verify: bool = True) -> PDFDocument:
if verify:
header = open(path, 'rb').read(5)
if header != b'%PDF-':
# TODO: MOVE TO def before() method after upgrading utilo
utilo.error('invalid pdf header')
sys.exit(1)
# TODO: MOVE TO def before() method after upgrading utilo ?
utilo.exitx('invalid pdf header')
with open(path, 'rb') as fp:
# Create a PDF parser object associated with the file object.
parser = PDFParser(fp)
Expand Down
1 change: 0 additions & 1 deletion tests/spacestation_/test_worddist.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ def test_worddist(source, pages, expected, td, mp):
loaded = serializeraw.load_document_worddist(td.tmpdir)
# verify
fontsize, chardist = expected
# TODO: REPLACE WITH VERY NEAR
assert utilo.near(loaded.mean[fontsize], chardist, diff=0.01), str(loaded)
4 changes: 1 addition & 3 deletions tests/test_horizontals.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ def test_lines_master099c(td, mp):
cmd = f'-i {hoverpower.MASTER099C_PDF} --pages=7,8,9,10,80,81,82 --line --horizontals'
tests.run(cmd, mp=mp)
lines = serializeraw.load_horizontals(td.tmpdir)
boundings = []
for page in lines:
boundings.append((page.page, page.content[0].box[3]))
boundings = [(page.page, page.content[0].box[3]) for page in lines]
# page, horizontal y1 bounding
expected = [
(7, 618.6),
Expand Down