flinventory 0.6.1__tar.gz → 0.6.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flinventory-0.6.1 → flinventory-0.6.3}/PKG-INFO +1 -1
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/constant.py +14 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/signprinter_latex.py +69 -18
- {flinventory-0.6.1 → flinventory-0.6.3}/pyproject.toml +1 -1
- {flinventory-0.6.1 → flinventory-0.6.3}/LICENSE +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/README.md +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/__init__.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/__main__.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/box.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/datacleanup.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/defaulted_data.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/generate_labels.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/inventory_io.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/location.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/sign.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/thing.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/thingtemplate_latex/.gitignore +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/thingtemplate_latex/dummyImage.jpg +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/thingtemplate_latex/sign.tex +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/thingtemplate_latex/signlist-footer.tex +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/thingtemplate_latex/signlist-header.tex +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/flinventory/thingtemplate_latex/signs-example.tex +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/tests/__init__.py +0 -0
- {flinventory-0.6.1 → flinventory-0.6.3}/tests/test_defaulted_data.py +0 -0
@@ -283,3 +283,17 @@ def fix_deprecated_language_keys(
|
|
283
283
|
)
|
284
284
|
# else: new_key not in data
|
285
285
|
data[new_key] = {language: data[key]}
|
286
|
+
|
287
|
+
|
288
|
+
class MissingProgramError(OSError):
|
289
|
+
"""Error raised if an external program is called that does not exist."""
|
290
|
+
|
291
|
+
def __init__(self, program_name: str, *args):
|
292
|
+
"""Create a MissingProgramError.
|
293
|
+
|
294
|
+
Args:
|
295
|
+
program_name: the name of the missing program
|
296
|
+
see OSError
|
297
|
+
"""
|
298
|
+
super().__init__(*args)
|
299
|
+
self.program_name = program_name
|
@@ -13,6 +13,7 @@ from typing import Union, Iterable, Optional
|
|
13
13
|
|
14
14
|
from .box import BoxedThing
|
15
15
|
from .sign import Sign
|
16
|
+
import constant
|
16
17
|
|
17
18
|
from . import thingtemplate_latex
|
18
19
|
|
@@ -23,6 +24,14 @@ TEMPLATE_POST = "signlist-footer.tex"
|
|
23
24
|
TEMPLATE_SIGN = "sign.tex"
|
24
25
|
DUMMY_IMAGE = "dummyImage.jpg"
|
25
26
|
AUX_DIR = "latexAux"
|
27
|
+
LATEXMK_OPTIONS = [
|
28
|
+
"latexmk",
|
29
|
+
f"-aux-directory={AUX_DIR}",
|
30
|
+
"-pdf",
|
31
|
+
"-interaction=nonstopmode",
|
32
|
+
"-f",
|
33
|
+
]
|
34
|
+
# only the tex file needs to be added to the list
|
26
35
|
|
27
36
|
UNIT = "cm" # todo: replace by length_unit in options, includes scaling the constants
|
28
37
|
# estimated by one example word
|
@@ -478,14 +487,30 @@ class SignPrinterLaTeX:
|
|
478
487
|
return file_signs
|
479
488
|
|
480
489
|
def create_signs_pdf(self, things: list[BoxedThing]):
|
481
|
-
"""Create a pdf and latex files with signs.
|
490
|
+
"""Create a pdf and latex files with signs.
|
491
|
+
|
492
|
+
Raises:
|
493
|
+
ProgramMissingError: if no latexmk is available
|
494
|
+
"""
|
482
495
|
self.save_signs_latex(things)
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
496
|
+
try:
|
497
|
+
latex = subprocess.run(
|
498
|
+
LATEXMK_OPTIONS + [self.signs_file],
|
499
|
+
cwd=self.output_dir,
|
500
|
+
capture_output=True,
|
501
|
+
text=True,
|
502
|
+
) # text=True makes output a str instead of bytes
|
503
|
+
except FileNotFoundError as program_missing:
|
504
|
+
if program_missing.filename == LATEXMK_OPTIONS[0]:
|
505
|
+
raise constant.MissingProgramError(
|
506
|
+
LATEXMK_OPTIONS[0],
|
507
|
+
program_missing.errno,
|
508
|
+
f"Program {LATEXMK_OPTIONS[0]} missing.",
|
509
|
+
program_missing.filename,
|
510
|
+
program_missing.winerror,
|
511
|
+
) from program_missing
|
512
|
+
else:
|
513
|
+
raise program_missing
|
489
514
|
with open(
|
490
515
|
os.path.join(self.output_dir, AUX_DIR, "latex_output.txt"), mode="w"
|
491
516
|
) as stdout_file:
|
@@ -507,6 +532,8 @@ class SignPrinterLaTeX:
|
|
507
532
|
thing: the thing which sign should be created
|
508
533
|
Returns:
|
509
534
|
path of the created svg file. None if error
|
535
|
+
Raises:
|
536
|
+
ProgramMissingError: if latexmk or pdf2svg is not available
|
510
537
|
"""
|
511
538
|
tex = self.create_latex_single_sign(thing)
|
512
539
|
tex_hash = str(abs(hash(tex)))
|
@@ -521,12 +548,24 @@ class SignPrinterLaTeX:
|
|
521
548
|
return file_svg
|
522
549
|
with open(path_tex, mode="w") as file_tex_f:
|
523
550
|
file_tex_f.write(tex)
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
551
|
+
try:
|
552
|
+
latex = subprocess.run(
|
553
|
+
LATEXMK_OPTIONS + [file_tex],
|
554
|
+
cwd=self.output_dir,
|
555
|
+
capture_output=True,
|
556
|
+
text=True,
|
557
|
+
) # text=True makes output a str instead of bytes
|
558
|
+
except FileNotFoundError as program_missing:
|
559
|
+
if program_missing.filename == LATEXMK_OPTIONS[0]:
|
560
|
+
raise constant.MissingProgramError(
|
561
|
+
LATEXMK_OPTIONS[0],
|
562
|
+
program_missing.errno,
|
563
|
+
f"Program {LATEXMK_OPTIONS[0]} missing.",
|
564
|
+
program_missing.filename,
|
565
|
+
program_missing.winerror,
|
566
|
+
) from program_missing
|
567
|
+
else:
|
568
|
+
raise program_missing
|
530
569
|
with open(
|
531
570
|
os.path.join(self.output_dir, AUX_DIR, f"latex_output_{tex_hash}.txt"),
|
532
571
|
mode="w",
|
@@ -546,11 +585,23 @@ class SignPrinterLaTeX:
|
|
546
585
|
self.logger.error(error_message)
|
547
586
|
print(error_message)
|
548
587
|
return None
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
588
|
+
try:
|
589
|
+
svg = subprocess.run(
|
590
|
+
["pdf2svg", path_pdf, path_svg],
|
591
|
+
capture_output=True,
|
592
|
+
text=True,
|
593
|
+
) # text=True makes output a str instead of bytes
|
594
|
+
except FileNotFoundError as program_missing:
|
595
|
+
if program_missing.filename == "pdf2svg":
|
596
|
+
raise constant.MissingProgramError(
|
597
|
+
"pdf2svg",
|
598
|
+
program_missing.errno,
|
599
|
+
"Program pdf2svg missing.",
|
600
|
+
program_missing.filename,
|
601
|
+
program_missing.winerror,
|
602
|
+
) from program_missing
|
603
|
+
else:
|
604
|
+
raise program_missing
|
554
605
|
with open(
|
555
606
|
os.path.join(self.output_dir, AUX_DIR, f"svg_output_{tex_hash}.txt"),
|
556
607
|
mode="w",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|