diff --git a/preprocess_cancellation.py b/preprocess_cancellation.py index 270926a..a5e89f2 100644 --- a/preprocess_cancellation.py +++ b/preprocess_cancellation.py @@ -5,14 +5,15 @@ import json import logging import pathlib -import platform import re import shutil import statistics import sys import tempfile -import time -from typing import Any, Dict, List, NamedTuple, Optional, Set, Tuple, TypeVar +from typing import Dict, List, NamedTuple, Optional, Set, Tuple, TypeVar + +__version__ = "0.1.7" + logging.basicConfig(stream=sys.stderr, level=logging.INFO) logger = logging.getLogger("prepropress_cancellation") @@ -25,8 +26,7 @@ except OSError: logger.exception("Failed to import shapely. Are you missing libgeos?") - -HEADER_MARKER = "; Pre-Processed for Cancel-Object support\n" +HEADER_MARKER = f"; Pre-Processed for Cancel-Object support by preprocess_cancellation v{__version__}\n" PathLike = TypeVar("PathLike", str, pathlib.Path) @@ -332,15 +332,19 @@ def preprocess_slicer(infile): infile.seek(0) for line in infile: yield line + if line.strip() and not line.startswith(";"): + break - if line.startswith("; generated by"): - yield from header(len(known_objects)) - for object_id, hull in known_objects.values(): - yield from define_object( - object_id, - center=hull.center(), - polygon=hull.exterior(), - ) + yield from header(len(known_objects)) + for object_id, hull in known_objects.values(): + yield from define_object( + object_id, + center=hull.center(), + polygon=hull.exterior(), + ) + + for line in infile: + yield line if line.startswith("; printing object "): yield from object_start_marker(known_objects[line.split("printing object")[1].strip()].name) diff --git a/pyproject.toml b/pyproject.toml index 40fa674..22d44c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "preprocess_cancellation" -version = "0.1.6" +version = "0.1.7" description = "GCode processor to add klipper cancel-object markers" readme = "README.md" authors = ["Franklyn Tackitt "]