Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mmu attributes parsing #42

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions gcode_metadata/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
r"((?P<seconds>[0-9]+)s)?")

PRINTERS = [
'MK4IS', 'MK4MMU3', 'MK4', 'MK3SMMU3', 'MK3MMU3', 'MK3SMMU2S',
'MK3MMU2', 'MK3S', 'MK3', 'MK2.5SMMU2S', 'MK2.5MMU2', 'MK2.5S',
'MK2.5', 'MK3.5', 'MK3.9', 'MINI', 'MINIIS', 'XL5', 'XL4', 'XL3',
'XL2', 'XL', 'iX', 'SL1', 'SHELF', 'EXTRACTOR', 'HARVESTER'
]
'MK4IS', 'MK4MMU3', 'MK4', 'MK3SMMU3', 'MK3MMU3', 'MK3SMMU2S', 'MK3MMU2',
'MK3S', 'MK3', 'MK2.5SMMU2S', 'MK2.5MMU2', 'MK2.5S', 'MK2.5', 'MK3.5',
'MK3.9', 'MINI', 'MINIIS', 'XL5', 'XL4', 'XL3', 'XL2', 'XL', 'iX', 'SL1',
'SHELF', 'EXTRACTOR', 'HARVESTER'
]

PRINTERS.sort(key=len, reverse=True)

MATERIALS = [
'PLA', 'PETG', 'ABS', 'ASA', 'FLEX', 'HIPS', 'EDGE', 'NGEN', 'PA',
'PVA', 'PCTG', 'PP', 'PC', 'PEBA', 'CPE', 'PVB', 'PET', 'PLA Tough',
'METAL', 'TPU', 'NYLON'
'PLA', 'PETG', 'ABS', 'ASA', 'FLEX', 'HIPS', 'EDGE', 'NGEN', 'PA', 'PVA',
'PCTG', 'PP', 'PC', 'PEBA', 'CPE', 'PVB', 'PET', 'PLA Tough', 'METAL',
'TPU', 'NYLON'
]

IMAGE_FORMATS = ['PNG', 'JPG']
Expand Down Expand Up @@ -440,10 +440,13 @@ def from_string(self, raw_value):

class FDMMetaData(MetaData):
"""Class for extracting Metadata for FDM gcodes"""

# pylint: disable=too-many-instance-attributes

def set_attr(self, name, value):
"""Set an attribute, but add support for mmu list attributes"""
if value == '""': # e.g. when no extruder_colour
return
if name in self.MMUAttrs:
value_list, single_value = self.MMUAttrs[name].from_string(value)
mmu_name = get_mmu_name(name)
Expand Down Expand Up @@ -489,6 +492,10 @@ def set_attr(self, name, value):
"nozzle_diameter":
MMUAttribute(separator=",",
value_type=float,
conversion=same_or_nothing),
"extruder_colour":
MMUAttribute(separator=";",
value_type=str,
conversion=same_or_nothing)
}

Expand Down Expand Up @@ -613,8 +620,7 @@ def from_comment_line(self, line):

# We store the image data only during parsing. If actively parsing:
if self.img is not None:
line = line[2:].strip()
self.img.append(line)
self.img.append(line[2:].strip())

# For the bulk of metadata comments
match = self.KEY_VAL_PAT.match(line)
Expand Down
Loading
Loading