Browse Source

Menší změny po code review s @wipocket.

error-handling
Jan Černohorský 1 year ago
parent
commit
0f7ed0ae32
  1. 6
      src/formatitko/command_util.py
  2. 2
      src/formatitko/context.py
  3. 1
      src/formatitko/images.py
  4. 2
      src/formatitko/tex_generator.py

6
src/formatitko/command_util.py

@ -16,9 +16,9 @@ def parse_command(code: str) -> CommandCallable:
for line in code_lines:
indented_code_lines.append(("\t" if tabs else " ")+line)
code = "def command(element: Command, context: Context) -> list[Element]:\n"+"\n".join(indented_code_lines)
globals = command_env.__dict__
exec(code, globals)
return globals["command"]
command_env = command_env.__dict__
exec(code, command_env)
return command_env["command"]
# This function is called in trasform.py, defining a command which can be
# called later

2
src/formatitko/context.py

@ -63,7 +63,7 @@ class Context:
self.set_command(prefix+name, func)
def is_flag_set(self, flag: str):
if self.get_metadata("flags."+flag):
if self.get_metadata("flags."+flag) is not None:
if self.get_metadata("flags."+flag):
return True
else:

1
src/formatitko/images.py

@ -125,7 +125,6 @@ class ImageProcessor:
return False
def publish_image(self, target_name, relative: bool=True) -> str:
import sys
cache_path = self.cache_dir + "/" + target_name
if not os.path.isfile(cache_path):
raise FileNotFoundError(f'Image {target_name} not cached')

2
src/formatitko/tex_generator.py

@ -123,7 +123,7 @@ class UCWTexGenerator(OutputGenerator):
# processing contains finding and moving them to the cache
# directory.
url = self.imageProcessor.process_image(url, ext, source_dir, **additional_args)
elif ext in ["svg"]:
elif ext in ["svg"]: # FIXME
url = self.imageProcessor.process_image(url, "pdf", source_dir, **additional_args)
elif ext in ["epdf"]:
url = self.imageProcessor.process_image(url, "pdf", source_dir, **additional_args)

Loading…
Cancel
Save