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.
- {tinyprint-0.2.3 → tinyprint-0.2.4}/PKG-INFO +1 -1
- {tinyprint-0.2.3 → tinyprint-0.2.4}/pyproject.toml +1 -1
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/gui.py +1 -1
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/preprocessor.py +10 -10
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/PKG-INFO +1 -1
- {tinyprint-0.2.3 → tinyprint-0.2.4}/LICENSE +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/README.md +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/setup.cfg +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tests/test_gui.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tests/test_integration.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tests/test_job.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tests/test_jobconfig.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/__init__.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/__main__.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/config.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/gui_misc.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/job.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/jobconfig.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/patches/__init__.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/patches/escpos.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/patches/mako.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/printer/__init__.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/printer/manager.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint/printer/profile.py +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/SOURCES.txt +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/dependency_links.txt +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/entry_points.txt +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/requires.txt +0 -0
- {tinyprint-0.2.3 → tinyprint-0.2.4}/tinyprint.egg-info/top_level.txt +0 -0
|
@@ -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
|
|
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
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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):
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|