Skip to content

Commit

Permalink
fix dimension words (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolflu05 authored Mar 5, 2024
1 parent 637f6b8 commit 4518e0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inventree_bulk_plugin/BulkGenerator/dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def parse_dimension(dimension: str) -> list[tuple[GeneratorTypes, Union[str, tuple[str, str]], dict, str]]:
res = []
for gen_match in re.finditer(r"(?:(?:(\w+)-(\w+))|(\*?\w+))(?:\((.*?)\))?(?:,|$)", dimension):
for gen_match in re.finditer(r"(?:(?:(\w+)-(\w+))|(\*?.+?))(?:\((.*?)\))?(?:,|$)", dimension):
settings = {}
if gen_match.group(4):
for setting_match in re.finditer(r"([A-Za-z_]+?)(?:=)([^=]+)(?:,|$)", gen_match.group(4)):
Expand Down
8 changes: 8 additions & 0 deletions inventree_bulk_plugin/tests/unit/test_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ def test_parse_dimension(self):
(GeneratorTypes.INFINITY, "abc", {"a": "1", "b": "'(2,3)'", "c": "4"}, "*abc(a=1,b='(2,3)',c=4)"),
(GeneratorTypes.RANGE, ("1", "3"), {"a": "1"}, "1-3(a=1)")
]),
("hello world,1-3,0.1,0.2,*TEST(a=1),0.3", [
(GeneratorTypes.WORD, "hello world", {}, "hello world"),
(GeneratorTypes.RANGE, ("1", "3"), {}, "1-3"),
(GeneratorTypes.WORD, "0.1", {}, "0.1"),
(GeneratorTypes.WORD, "0.2", {}, "0.2"),
(GeneratorTypes.INFINITY, "TEST", {"a": "1"}, "*TEST(a=1)"),
(GeneratorTypes.WORD, "0.3", {}, "0.3"),
]),
]

for test_str, expected_generators in cases:
Expand Down

0 comments on commit 4518e0c

Please sign in to comment.