Skip to content

Commit

Permalink
Permit special chars in literals (#3)
Browse files Browse the repository at this point in the history
Adds support for using the following special characters in literal groups:
. : \ / - _
  • Loading branch information
LavissaWoW authored May 10, 2024
1 parent 6691bbb commit cb1772a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ipn_generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

logger = logging.getLogger("inventree")

PERMITTED_SPECIAL_LITERALS = "\-.:/\\"


def validate_pattern(pattern):
"""Validates pattern groups"""
Expand Down Expand Up @@ -118,7 +120,7 @@ def construct_regex(self, disable_groups=False):
regex = "^"

m = re.findall(
r"(\{\d+\+?\})|(\([\w\(\)]+\))|(\[(?:\w+|\w-\w)+\])",
r"(\{\d+\+?\})|(\([\w\(\)\-.:/\\]+\))|(\[(?:\w+|\w-\w)+\])",
self.get_setting("PATTERN"),
)

Expand Down Expand Up @@ -248,7 +250,7 @@ def increment_ipn(self, exp, latest):
def construct_first_ipn(self):
"""No IPNs matching the pattern were found. Constructing the first IPN."""
m = re.findall(
r"(\{\d+\+?\})|(\([\w\(\)]+\))|(\[(?:\w+|(?:\w-\w)+)\])",
r"(\{\d+\+?\})|(\([\w\(\)\-.:/\\]+\))|(\[(?:\w+|(?:\w-\w)+)\])",
self.get_setting("PATTERN"),
)

Expand Down

0 comments on commit cb1772a

Please sign in to comment.