summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/GroupPatterns.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Plugins/GroupPatterns.py')
-rw-r--r--src/lib/Server/Plugins/GroupPatterns.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/Server/Plugins/GroupPatterns.py b/src/lib/Server/Plugins/GroupPatterns.py
index 76a628931..7733f409f 100644
--- a/src/lib/Server/Plugins/GroupPatterns.py
+++ b/src/lib/Server/Plugins/GroupPatterns.py
@@ -25,7 +25,7 @@ class PackedDigitRange(object):
class PatternMap(object):
- range_finder = '\\[\\[[\d\-,]+\\]\\]'
+ range_finder = r'\[\[[\d\-,]+\]\]'
def __init__(self, pattern, rangestr, groups):
self.pattern = pattern
@@ -35,15 +35,18 @@ class PatternMap(object):
self.re = re.compile(pattern)
self.process = self.process_re
elif rangestr != None:
+ if '\\' in rangestr:
+ raise Exception("Backslashes are not allowed in NameRanges")
self.process = self.process_range
- self.re = re.compile('^' + re.subn(self.range_finder, '(\d+)',
- rangestr)[0])
- dmatcher = re.compile(re.subn(self.range_finder,
- '\\[\\[([\d\-,]+)\\]\\]',
- rangestr)[0])
- self.dranges = [PackedDigitRange(x) for x in dmatcher.match(rangestr).groups()]
+ self.re = re.compile('^' + re.sub(self.range_finder, '(\d+)',
+ rangestr))
+ dmatcher = re.compile(re.sub(self.range_finder,
+ r'\[\[([\d\-,]+)\]\]',
+ rangestr))
+ self.dranges = [PackedDigitRange(x)
+ for x in dmatcher.match(rangestr).groups()]
else:
- raise Exception
+ raise Exception("No pattern or range given")
def process_range(self, name):
match = self.re.match(name)