flinventory 0.6.2__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.
Files changed (24) hide show
  1. {flinventory-0.6.2 → flinventory-0.6.3}/PKG-INFO +1 -1
  2. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/constant.py +14 -0
  3. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/signprinter_latex.py +61 -18
  4. {flinventory-0.6.2 → flinventory-0.6.3}/pyproject.toml +1 -1
  5. {flinventory-0.6.2 → flinventory-0.6.3}/LICENSE +0 -0
  6. {flinventory-0.6.2 → flinventory-0.6.3}/README.md +0 -0
  7. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/__init__.py +0 -0
  8. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/__main__.py +0 -0
  9. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/box.py +0 -0
  10. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/datacleanup.py +0 -0
  11. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/defaulted_data.py +0 -0
  12. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/generate_labels.py +0 -0
  13. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/inventory_io.py +0 -0
  14. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/location.py +0 -0
  15. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/sign.py +0 -0
  16. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/thing.py +0 -0
  17. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/thingtemplate_latex/.gitignore +0 -0
  18. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/thingtemplate_latex/dummyImage.jpg +0 -0
  19. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/thingtemplate_latex/sign.tex +0 -0
  20. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/thingtemplate_latex/signlist-footer.tex +0 -0
  21. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/thingtemplate_latex/signlist-header.tex +0 -0
  22. {flinventory-0.6.2 → flinventory-0.6.3}/flinventory/thingtemplate_latex/signs-example.tex +0 -0
  23. {flinventory-0.6.2 → flinventory-0.6.3}/tests/__init__.py +0 -0
  24. {flinventory-0.6.2 → flinventory-0.6.3}/tests/test_defaulted_data.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flinventory
3
- Version: 0.6.2
3
+ Version: 0.6.3
4
4
  Summary: An inventory system for self-help repair shops
5
5
  Author-Email: flukx <flinventory-flukx@612211124.xyz>
6
6
  License: GPL3
@@ -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
 
@@ -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
- latex = subprocess.run(
492
- LATEXMK_OPTIONS + [self.signs_file],
493
- cwd=self.output_dir,
494
- capture_output=True,
495
- text=True,
496
- ) # text=True makes output a str instead of bytes
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
- latex = subprocess.run(
533
- LATEXMK_OPTIONS + [file_tex],
534
- cwd=self.output_dir,
535
- capture_output=True,
536
- text=True,
537
- ) # text=True makes output a str instead of bytes
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
- svg = subprocess.run(
558
- ["pdf2svg", path_pdf, path_svg],
559
- capture_output=True,
560
- text=True,
561
- ) # text=True makes output a str instead of bytes
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,6 +1,6 @@
1
1
  [project]
2
2
  name = "flinventory"
3
- version = "0.6.2"
3
+ version = "0.6.3"
4
4
  description = "An inventory system for self-help repair shops"
5
5
  authors = [
6
6
  { name = "flukx", email = "flinventory-flukx@612211124.xyz" },
File without changes
File without changes