metadata: simplify the S3Dv5 temp regex

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-02-21 06:24:17 -05:00
parent 7845390dd1
commit 522fdab63d
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B

View File

@ -17,7 +17,6 @@ import tempfile
import zipfile import zipfile
import shutil import shutil
import uuid import uuid
import io
from PIL import Image from PIL import Image
# Annotation imports # Annotation imports
@ -646,35 +645,18 @@ class Simplify3D(BaseSlicer):
return None return None
return None return None
def _get_first_layer_temp_v5(self, type: str) -> Optional[float]: def _get_first_layer_temp_v5(self, heater_type: str) -> Optional[float]:
matches = re.finditer(r";\s+temperatureController.*", self.header_data) pattern = (
r";\s+temperatureController,.+?"
for m in matches: r";\s+temperatureType,"f"{heater_type}"r".+?"
typ = None r";\s+temperatureSetpoints,\d+\|(\d+)"
temp = None )
match = re.search(pattern, self.header_data, re.MULTILINE | re.DOTALL)
for line in io.StringIO(self.header_data[m.end()+1:]): if match is not None:
if not line.startswith(";"): try:
break return float(match.group(1))
except Exception:
if re.search(r";\s+temperatureController", line): return None
break
val_temp = _regex_find_first(
r";\s+temperatureSetpoints,\d+\|(\d+)", line)
if val_temp:
temp = val_temp
val_typ = _regex_find_string(r"\s+temperatureType,(.+)", line)
if val_typ:
typ = val_typ
if typ and temp:
break
if typ == type:
return temp
return None return None
def parse_first_layer_extr_temp(self) -> Optional[float]: def parse_first_layer_extr_temp(self) -> Optional[float]: