mirror of
https://github.com/enzet/map-machine.git
synced 2025-08-02 16:19:20 +02:00
Add compiled matchers.
Compile matchers instead of creating new one every time.
This commit is contained in:
parent
3dcb3e894a
commit
ba4b338327
1 changed files with 5 additions and 3 deletions
|
@ -24,9 +24,11 @@ __email__ = "me@enzet.ru"
|
|||
DEFAULT_COLOR: Color = Color("#444444")
|
||||
DEFAULT_SHAPE_ID: str = "default"
|
||||
DEFAULT_SMALL_SHAPE_ID: str = "default_small"
|
||||
STANDARD_INKSCAPE_ID: str = (
|
||||
|
||||
STANDARD_INKSCAPE_ID_MATCHER = re.compile(
|
||||
"^((circle|defs|ellipse|metadata|path|rect|use)[\\d-]+|base)$"
|
||||
)
|
||||
PATH_MATCHER = re.compile("[Mm] ([0-9.e-]*)[, ]([0-9.e-]*)")
|
||||
|
||||
GRID_STEP: int = 16
|
||||
|
||||
|
@ -156,12 +158,12 @@ class ShapeExtractor:
|
|||
return
|
||||
|
||||
id_: str = node.getAttribute("id")
|
||||
if re.match(STANDARD_INKSCAPE_ID, id_) is not None:
|
||||
if STANDARD_INKSCAPE_ID_MATCHER.match(id_) is not None:
|
||||
return
|
||||
|
||||
if node.hasAttribute("d"):
|
||||
path: str = node.getAttribute("d")
|
||||
matcher = re.match("[Mm] ([0-9.e-]*)[, ]([0-9.e-]*)", path)
|
||||
matcher = PATH_MATCHER.match(path)
|
||||
if not matcher:
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue