Commit 60abf805 authored by Nathan Lee's avatar Nathan Lee Committed by Martin Owens

Fix hpgl output: pen number regex

Fix #275
parent d8750d09
......@@ -32,7 +32,7 @@ class NoPathError(ValueError):
"""Raise that paths not selected"""
# Find the pen number in the layer number
FIND_PEN = re.compile(r'(\s|\A)pen\s*(\d+)(\s|\Z)')
FIND_PEN = re.compile(r'\s*pen\s*(\d+)\s*', re.IGNORECASE)
class hpglEncoder(object):
"""HPGL Encoder, used by others"""
......@@ -190,9 +190,9 @@ class hpglEncoder(object):
def get_pen_number(self, node):
"""Get pen number for node label (usually group)"""
for parent in [node] + list(node.ancestors().values()):
match = fullmatch(FIND_PEN, parent.label or '', re.IGNORECASE)
match = fullmatch(FIND_PEN, parent.label or '')
if match:
return int(match.group(2))
return int(match.group(1))
return int(self.options.pen)
def process_path(self, node, transform):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment