flinventory 0.6.2__py3-none-any.whl → 0.6.4__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 -19
- {flinventory-0.6.2.dist-info → flinventory-0.6.4.dist-info}/METADATA +1 -1
- {flinventory-0.6.2.dist-info → flinventory-0.6.4.dist-info}/RECORD +7 -7
- {flinventory-0.6.2.dist-info → flinventory-0.6.4.dist-info}/WHEEL +0 -0
- {flinventory-0.6.2.dist-info → flinventory-0.6.4.dist-info}/entry_points.txt +0 -0
- {flinventory-0.6.2.dist-info → flinventory-0.6.4.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,7 +13,7 @@ from typing import Union, Iterable, Optional
|
|
13
13
|
|
14
14
|
from .box import BoxedThing
|
15
15
|
from .sign import Sign
|
16
|
-
|
16
|
+
from . import constant
|
17
17
|
from . import thingtemplate_latex
|
18
18
|
|
19
19
|
TEMPLATE_PACKAGE = thingtemplate_latex
|
@@ -486,14 +486,30 @@ class SignPrinterLaTeX:
|
|
486
486
|
return file_signs
|
487
487
|
|
488
488
|
def create_signs_pdf(self, things: list[BoxedThing]):
|
489
|
-
"""Create a pdf and latex files with signs.
|
489
|
+
"""Create a pdf and latex files with signs.
|
490
|
+
|
491
|
+
Raises:
|
492
|
+
ProgramMissingError: if no latexmk is available
|
493
|
+
"""
|
490
494
|
self.save_signs_latex(things)
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
495
|
+
try:
|
496
|
+
latex = subprocess.run(
|
497
|
+
LATEXMK_OPTIONS + [self.signs_file],
|
498
|
+
cwd=self.output_dir,
|
499
|
+
capture_output=True,
|
500
|
+
text=True,
|
501
|
+
) # text=True makes output a str instead of bytes
|
502
|
+
except FileNotFoundError as program_missing:
|
503
|
+
if program_missing.filename == LATEXMK_OPTIONS[0]:
|
504
|
+
raise constant.MissingProgramError(
|
505
|
+
LATEXMK_OPTIONS[0],
|
506
|
+
program_missing.errno,
|
507
|
+
f"Program {LATEXMK_OPTIONS[0]} missing.",
|
508
|
+
program_missing.filename,
|
509
|
+
program_missing.winerror,
|
510
|
+
) from program_missing
|
511
|
+
else:
|
512
|
+
raise program_missing
|
497
513
|
with open(
|
498
514
|
os.path.join(self.output_dir, AUX_DIR, "latex_output.txt"), mode="w"
|
499
515
|
) as stdout_file:
|
@@ -515,6 +531,8 @@ class SignPrinterLaTeX:
|
|
515
531
|
thing: the thing which sign should be created
|
516
532
|
Returns:
|
517
533
|
path of the created svg file. None if error
|
534
|
+
Raises:
|
535
|
+
ProgramMissingError: if latexmk or pdf2svg is not available
|
518
536
|
"""
|
519
537
|
tex = self.create_latex_single_sign(thing)
|
520
538
|
tex_hash = str(abs(hash(tex)))
|
@@ -529,12 +547,24 @@ class SignPrinterLaTeX:
|
|
529
547
|
return file_svg
|
530
548
|
with open(path_tex, mode="w") as file_tex_f:
|
531
549
|
file_tex_f.write(tex)
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
550
|
+
try:
|
551
|
+
latex = subprocess.run(
|
552
|
+
LATEXMK_OPTIONS + [file_tex],
|
553
|
+
cwd=self.output_dir,
|
554
|
+
capture_output=True,
|
555
|
+
text=True,
|
556
|
+
) # text=True makes output a str instead of bytes
|
557
|
+
except FileNotFoundError as program_missing:
|
558
|
+
if program_missing.filename == LATEXMK_OPTIONS[0]:
|
559
|
+
raise constant.MissingProgramError(
|
560
|
+
LATEXMK_OPTIONS[0],
|
561
|
+
program_missing.errno,
|
562
|
+
f"Program {LATEXMK_OPTIONS[0]} missing.",
|
563
|
+
program_missing.filename,
|
564
|
+
program_missing.winerror,
|
565
|
+
) from program_missing
|
566
|
+
else:
|
567
|
+
raise program_missing
|
538
568
|
with open(
|
539
569
|
os.path.join(self.output_dir, AUX_DIR, f"latex_output_{tex_hash}.txt"),
|
540
570
|
mode="w",
|
@@ -554,11 +584,23 @@ class SignPrinterLaTeX:
|
|
554
584
|
self.logger.error(error_message)
|
555
585
|
print(error_message)
|
556
586
|
return None
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
587
|
+
try:
|
588
|
+
svg = subprocess.run(
|
589
|
+
["pdf2svg", path_pdf, path_svg],
|
590
|
+
capture_output=True,
|
591
|
+
text=True,
|
592
|
+
) # text=True makes output a str instead of bytes
|
593
|
+
except FileNotFoundError as program_missing:
|
594
|
+
if program_missing.filename == "pdf2svg":
|
595
|
+
raise constant.MissingProgramError(
|
596
|
+
"pdf2svg",
|
597
|
+
program_missing.errno,
|
598
|
+
"Program pdf2svg missing.",
|
599
|
+
program_missing.filename,
|
600
|
+
program_missing.winerror,
|
601
|
+
) from program_missing
|
602
|
+
else:
|
603
|
+
raise program_missing
|
562
604
|
with open(
|
563
605
|
os.path.join(self.output_dir, AUX_DIR, f"svg_output_{tex_hash}.txt"),
|
564
606
|
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.4.dist-info/METADATA,sha256=MeKw6qQOmVaa_wkMbCDgFklu1wltWA0xLxAD26DeOoA,4907
|
2
|
+
flinventory-0.6.4.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
3
|
+
flinventory-0.6.4.dist-info/entry_points.txt,sha256=De3jjbHfy68_ZrwdjywlgrSUCn4QhqZGI0CJJt9S8_c,78
|
4
|
+
flinventory-0.6.4.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=XgboTit6u_AlK68s4I84l7uFeZJC_yb3SvLOdPLnQH4,24825
|
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.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|