tinyprint 0.2.3__tar.gz → 0.2.4__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 (29) hide show
  1. {tinyprint-0.2.3 → tinyprint-0.2.4}/PKG-INFO +1 -1
  2. {tinyprint-0.2.3 → tinyprint-0.2.4}/pyproject.toml +1 -1
  3. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/gui.py +1 -1
  4. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/preprocessor.py +10 -10
  5. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/PKG-INFO +1 -1
  6. {tinyprint-0.2.3 → tinyprint-0.2.4}/LICENSE +0 -0
  7. {tinyprint-0.2.3 → tinyprint-0.2.4}/README.md +0 -0
  8. {tinyprint-0.2.3 → tinyprint-0.2.4}/setup.cfg +0 -0
  9. {tinyprint-0.2.3 → tinyprint-0.2.4}/tests/test_gui.py +0 -0
  10. {tinyprint-0.2.3 → tinyprint-0.2.4}/tests/test_integration.py +0 -0
  11. {tinyprint-0.2.3 → tinyprint-0.2.4}/tests/test_job.py +0 -0
  12. {tinyprint-0.2.3 → tinyprint-0.2.4}/tests/test_jobconfig.py +0 -0
  13. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/__init__.py +0 -0
  14. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/__main__.py +0 -0
  15. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/config.py +0 -0
  16. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/gui_misc.py +0 -0
  17. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/job.py +0 -0
  18. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/jobconfig.py +0 -0
  19. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/patches/__init__.py +0 -0
  20. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/patches/escpos.py +0 -0
  21. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/patches/mako.py +0 -0
  22. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/printer/__init__.py +0 -0
  23. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/printer/manager.py +0 -0
  24. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/printer/profile.py +0 -0
  25. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/SOURCES.txt +0 -0
  26. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/dependency_links.txt +0 -0
  27. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/entry_points.txt +0 -0
  28. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/requires.txt +0 -0
  29. {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tinyprint
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: ui & cli to print zines with esc/pos printer
5
5
  Author-email: Levin Eric Zimmermann <levin.eric.zimmermann@posteo.com>
6
6
  License: GPL
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tinyprint"
3
- version = "0.2.3"
3
+ version = "0.2.4"
4
4
  authors = [
5
5
  {name = "Levin Eric Zimmermann", email = "levin.eric.zimmermann@posteo.com"},
6
6
  ]
@@ -226,7 +226,7 @@ class JobConfigEditor(Block):
226
226
  def select_file(self, attr, filetypes, multiple=False):
227
227
  file_list = super().select_file(filetypes, multiple)
228
228
  if multiple is False:
229
- file_list = [file_list]
229
+ file_list = [file_list] if file_list else []
230
230
  if file_list:
231
231
  setattr(
232
232
  self.job_config,
@@ -32,26 +32,26 @@ def create_pages_from_resources(config, printer_profile) -> tuple[Page, ...]:
32
32
  def get_preprocessor_for_resource(resource: Resource) -> type[Preprocessor]:
33
33
  """Return the appropriate preprocessor class for the given resource."""
34
34
  path = resource.path
35
- if _is_binary_file(path):
35
+ if _is_text_file(path):
36
+ return MarkdownPreprocessor
37
+ else:
36
38
  m = mimetypes.guess_type(path)
37
39
  if m[0]:
38
40
  if m[0].startswith("image"):
39
41
  return ImagePreprocessor
40
42
  elif m[0] == "application/pdf":
41
43
  return PdfPreprocessor
42
- else:
43
- return MarkdownPreprocessor
44
44
  raise NotImplementedError(f"can't guess type of {path}")
45
45
 
46
46
 
47
47
  # helper
48
- def _is_binary_file(path):
49
- with open(path, "rb") as f:
50
- header = f.read(1024)
51
- textchars = bytearray(
52
- {7, 8, 9, 10, 12, 13, 27} | set(range(0x20, 0x100)) - {0x7F},
53
- )
54
- return bool(header.translate(None, textchars))
48
+ def _is_text_file(path, blocksize=4096):
49
+ try:
50
+ with open(path, "rb") as f:
51
+ f.read(blocksize).decode("utf-8")
52
+ return True
53
+ except UnicodeDecodeError:
54
+ return False
55
55
 
56
56
 
57
57
  class Preprocessor(abc.ABC):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tinyprint
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: ui & cli to print zines with esc/pos printer
5
5
  Author-email: Levin Eric Zimmermann <levin.eric.zimmermann@posteo.com>
6
6
  License: GPL
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes