flinventory 0.6.2__py3-none-any.whl → 0.6.3__py3-none-any.whl
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/constant.py +14 -0
- flinventory/signprinter_latex.py +61 -18
- {flinventory-0.6.2.dist-info → flinventory-0.6.3.dist-info}/METADATA +1 -1
- {flinventory-0.6.2.dist-info → flinventory-0.6.3.dist-info}/RECORD +7 -7
- {flinventory-0.6.2.dist-info → flinventory-0.6.3.dist-info}/WHEEL +0 -0
- {flinventory-0.6.2.dist-info → flinventory-0.6.3.dist-info}/entry_points.txt +0 -0
- {flinventory-0.6.2.dist-info → flinventory-0.6.3.dist-info}/licenses/LICENSE +0 -0
flinventory/constant.py
CHANGED
@@ -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
|
flinventory/signprinter_latex.py
CHANGED
@@ -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
|
|
@@ -486,14 +487,30 @@ class SignPrinterLaTeX:
|
|
486
487
|
return file_signs
|
487
488
|
|
488
489
|
def create_signs_pdf(self, things: list[BoxedThing]):
|
489
|
-
"""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
|
+
"""
|
490
495
|
self.save_signs_latex(things)
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
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
|
497
514
|
with open(
|
498
515
|
os.path.join(self.output_dir, AUX_DIR, "latex_output.txt"), mode="w"
|
499
516
|
) as stdout_file:
|
@@ -515,6 +532,8 @@ class SignPrinterLaTeX:
|
|
515
532
|
thing: the thing which sign should be created
|
516
533
|
Returns:
|
517
534
|
path of the created svg file. None if error
|
535
|
+
Raises:
|
536
|
+
ProgramMissingError: if latexmk or pdf2svg is not available
|
518
537
|
"""
|
519
538
|
tex = self.create_latex_single_sign(thing)
|
520
539
|
tex_hash = str(abs(hash(tex)))
|
@@ -529,12 +548,24 @@ class SignPrinterLaTeX:
|
|
529
548
|
return file_svg
|
530
549
|
with open(path_tex, mode="w") as file_tex_f:
|
531
550
|
file_tex_f.write(tex)
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
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
|
538
569
|
with open(
|
539
570
|
os.path.join(self.output_dir, AUX_DIR, f"latex_output_{tex_hash}.txt"),
|
540
571
|
mode="w",
|
@@ -554,11 +585,23 @@ class SignPrinterLaTeX:
|
|
554
585
|
self.logger.error(error_message)
|
555
586
|
print(error_message)
|
556
587
|
return None
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
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
|
562
605
|
with open(
|
563
606
|
os.path.join(self.output_dir, AUX_DIR, f"svg_output_{tex_hash}.txt"),
|
564
607
|
mode="w",
|
@@ -1,18 +1,18 @@
|
|
1
|
-
flinventory-0.6.
|
2
|
-
flinventory-0.6.
|
3
|
-
flinventory-0.6.
|
4
|
-
flinventory-0.6.
|
1
|
+
flinventory-0.6.3.dist-info/METADATA,sha256=nOBNNUxpd1398oquOYvcKheoGbu00MQ4-0h6B4--NU0,4907
|
2
|
+
flinventory-0.6.3.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
3
|
+
flinventory-0.6.3.dist-info/entry_points.txt,sha256=De3jjbHfy68_ZrwdjywlgrSUCn4QhqZGI0CJJt9S8_c,78
|
4
|
+
flinventory-0.6.3.dist-info/licenses/LICENSE,sha256=9c-AWlAEeFMmn1aODEfabsw2he-SpQeykurYw-KqSdw,34478
|
5
5
|
flinventory/__init__.py,sha256=0HTGxw9J-2KnbxQbzX6HH-Pztkp0BEjiHANhndfbtYM,270
|
6
6
|
flinventory/__main__.py,sha256=5U_RxWDlnhzlC98RaE8SkejjiYjv27OLdm5DPYgL4Gw,1295
|
7
7
|
flinventory/box.py,sha256=rk7yrAjVdxcrpvmTMt3jkMVOAoQNJfqoSig9U2S3yJ0,10480
|
8
|
-
flinventory/constant.py,sha256=
|
8
|
+
flinventory/constant.py,sha256=4qb7gX-pQdr7fGq25dTkESe6B53yi4yILOF4Y8KtWk0,10672
|
9
9
|
flinventory/datacleanup.py,sha256=_CImmWJhq5uKz21jJQUqKYoQfbHEYA0000RyPRt5BI0,11363
|
10
10
|
flinventory/defaulted_data.py,sha256=KAy6V2KLcifLg7zHBFnx_eFLp31sCWih1Btp6cE0bQc,21585
|
11
11
|
flinventory/generate_labels.py,sha256=wjlyta9gowWOLvVfOVUQ8Ktpv3eg85JbAfDzI4Ok2V4,8476
|
12
12
|
flinventory/inventory_io.py,sha256=OWThcf9nzeZNqvNpzQiBhESQAnVXC7hUA8DEVzq-w-Y,12561
|
13
13
|
flinventory/location.py,sha256=UgJlbno16ipuFa4yUZK3SLrid70ACwE5He9Dd4P2SMU,16875
|
14
14
|
flinventory/sign.py,sha256=8G7fsne3Nsf8zZKKTUl40uWMNsWIv7FYV2KcqBR2MQI,5515
|
15
|
-
flinventory/signprinter_latex.py,sha256=
|
15
|
+
flinventory/signprinter_latex.py,sha256=3-5fUKYT4uzR8lEIsfMg4meJMgP_oiHQmqAzrNN7dgs,24819
|
16
16
|
flinventory/thing.py,sha256=86fXj3RwTbkCdVVWrbyO-VEW_e5lKJlV8PPt1Xf8ejY,5079
|
17
17
|
flinventory/thingtemplate_latex/.gitignore,sha256=DTF250Ttj8O2lxrQBwMNrQ73rWPvdwCytipfZSLFtlU,51
|
18
18
|
flinventory/thingtemplate_latex/dummyImage.jpg,sha256=bIBH5Lrxlr5qJ42nP1cpJXPRNGLOwyEuzwXFSvNwTSk,147857
|
@@ -20,4 +20,4 @@ flinventory/thingtemplate_latex/sign.tex,sha256=cVlOjImuS97Gf19MGW27HiP6Uw8JNnob
|
|
20
20
|
flinventory/thingtemplate_latex/signlist-footer.tex,sha256=LcZw5__h8SqgMmYxs5oLbXLaFTQlx_X5rtYnpxwUh9Y,14
|
21
21
|
flinventory/thingtemplate_latex/signlist-header.tex,sha256=F1J4aSPq6QO_Ved4Zn7-rytP1vDkdWTqjjtGJpe_FDg,297
|
22
22
|
flinventory/thingtemplate_latex/signs-example.tex,sha256=J6eCcPhP0Xklgn8xnSenDOvjzmc_NGmakWU4RGbeUtM,3090
|
23
|
-
flinventory-0.6.
|
23
|
+
flinventory-0.6.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|