Skip to content

Commit 4cbe404

Browse files
committed
asn1c: switch regexp to raw string
1 parent 9f4b4dc commit 4cbe404

File tree

3 files changed

+85
-85
lines changed

3 files changed

+85
-85
lines changed

pycrate_asn1c/asnobj.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ def _parse_tag(self, text):
17791779
val = int(valnum)
17801780
text = text[m.end():].strip()
17811781
# 3) get TAG mode
1782-
m = re.match('(IMPLICIT|EXPLICIT)(?:\s)', text)
1782+
m = re.match(r'(IMPLICIT|EXPLICIT)(?:\s)', text)
17831783
if m:
17841784
self._tag = [val, cla, m.group(1)]
17851785
text = text[m.end():].strip()
@@ -3675,7 +3675,7 @@ def _parse_cont_class(self, text):
36753675
else:
36763676
# 1.6) get potential type or typeref
36773677
if name[0].isupper() and (not field or \
3678-
re.match('(UNIQUE|OPTIONAL|DEFAULT)(\s{1,}|$)', field)):
3678+
re.match(r'(UNIQUE|OPTIONAL|DEFAULT)(\s{1,}|$)', field)):
36793679
# no type is provided, so this is must be an OPEN TYPE
36803680
Field._mode = MODE_TYPE
36813681
Field._type = TYPE_OPEN
@@ -3841,7 +3841,7 @@ def _parse_class_syntax(self, text):
38413841
# remove comas, as they are just here for beauty !
38423842
text = text.replace(',', '')
38433843
# replace any kind of space(s) with single white space
3844-
text = re.subn('\s{1,}', ' ', text)[0]
3844+
text = re.subn(r'\s{1,}', ' ', text)[0]
38453845
#
38463846
self._syntax = []
38473847
#
@@ -4802,7 +4802,7 @@ def _parse_value_null(self, text):
48024802
value is the integer 0
48034803
"""
48044804
# test NULL ::= NULL
4805-
m = re.match('(?:^|\s{1})(NULL)', text)
4805+
m = re.match(r'(?:^|\s{1})(NULL)', text)
48064806
if not m:
48074807
# reference to a local formal parameter identifier
48084808
# or a global identifier
@@ -4819,7 +4819,7 @@ def _parse_value_bool(self, text):
48194819
value is a boolean (Python bool)
48204820
"""
48214821
# test BOOLEAN ::= TRUE (/ FALSE)
4822-
m = re.match('(?:^|\s{1})(TRUE|FALSE)', text)
4822+
m = re.match(r'(?:^|\s{1})(TRUE|FALSE)', text)
48234823
if not m:
48244824
# reference to a local formal parameter identifier
48254825
# or a global identifier
@@ -4949,7 +4949,7 @@ def _parse_value_bitstr(self, text):
49494949
m = SYNT_RE_BSTRING.match(text)
49504950
if m:
49514951
# bstring
4952-
bs = re.subn('\s{1,}', '', m.group(1))[0]
4952+
bs = re.subn(r'\s{1,}', '', m.group(1))[0]
49534953
if not bs:
49544954
# null length bit string
49554955
val = [0, 0]
@@ -4961,7 +4961,7 @@ def _parse_value_bitstr(self, text):
49614961
m = SYNT_RE_HSTRING.match(text)
49624962
if m:
49634963
# hstring
4964-
hs = re.subn('\s{1,}', '', m.group(1))[0]
4964+
hs = re.subn(r'\s{1,}', '', m.group(1))[0]
49654965
if not hs:
49664966
# null length bit string
49674967
val = [0, 0]
@@ -5059,7 +5059,7 @@ def _parse_value_octstr(self, text):
50595059
m = SYNT_RE_BSTRING.match(text)
50605060
if m:
50615061
# bstring
5062-
bs = re.subn('\s{1,}', '', m.group(1))[0]
5062+
bs = re.subn(r'\s{1,}', '', m.group(1))[0]
50635063
if not bs:
50645064
# null length octet string
50655065
val = b''
@@ -5071,7 +5071,7 @@ def _parse_value_octstr(self, text):
50715071
m = SYNT_RE_HSTRING.match(text)
50725072
if m:
50735073
# hstring
5074-
hs = re.subn('\s{1,}', '', m.group(1))[0]
5074+
hs = re.subn(r'\s{1,}', '', m.group(1))[0]
50755075
if len(hs)%2:
50765076
val = unhexlify(hs + '0')
50775077
else:
@@ -6114,7 +6114,7 @@ def __parse_set_insert(self, val, objval, dom):
61146114

61156115
def _parse_value_or_range(self, text):
61166116
# check for the range marker ".."
6117-
m = re.search('[^.]\.\.[^.]', text)
6117+
m = re.search(r'[^.]\.\.[^.]', text)
61186118
if m:
61196119
if self._type == TYPE_INT:
61206120
ra = ASN1RangeInt()

pycrate_asn1c/asnproc.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def _compile_text_pass(text, with_order, **kwargs):
350350
# 3) scan text for BEGIN - END block
351351
# WNG: old school ASN.1 MACRO (with BEGIN - END block within ASN.1 module)
352352
# are not supported
353-
m = re.search('(^|\s)BEGIN(\s)((.|\n)*?)(\s)END($|\s)', text)
353+
m = re.search(r'(^|\s)BEGIN(\s)((.|\n)*?)(\s)END($|\s)', text)
354354
if not m:
355355
raise(ASN1ProcTextErr('[proc]{0} module {1}: BEGIN - END scheme not found'\
356356
.format(fn, name)))
@@ -610,7 +610,7 @@ def module_get_name(text, fn):
610610
name, oidstr = name_all[-1]
611611
# clean-up the oid
612612
if oidstr:
613-
oidstr = re.sub('\s{1,}', ' ', oidstr[1:-1]).strip()
613+
oidstr = re.sub(r'\s{1,}', ' ', oidstr[1:-1]).strip()
614614
else:
615615
oidstr = None
616616
return name, oidstr
@@ -641,7 +641,7 @@ def module_get_export(text=''):
641641
# remove CR
642642
exp = m.group(1).replace('\n', ',').strip()
643643
# remove duplicated spaces / comas
644-
exp = re.sub('[ ]{0,},{1,}[ ]{0,},{1,}[ ]{0,}', ', ', exp)
644+
exp = re.sub(r'[ ]{0,},{1,}[ ]{0,},{1,}[ ]{0,}', ', ', exp)
645645
# split, strip, and keep only strings
646646
exp = [s for s in map(strip, exp.split(',')) if s != '']
647647
return exp, m.end()
@@ -655,7 +655,7 @@ def module_get_import(text=''):
655655
if m:
656656
l = []
657657
imp = m.group(1).strip()
658-
if not re.match('\s{0,}', imp):
658+
if not re.match(r'\s{0,}', imp):
659659
# in case of "IMPORTS ;"
660660
return None, m.end()
661661
# take care of FROM directives, that can reference the complete module name
@@ -665,7 +665,7 @@ def module_get_import(text=''):
665665
cur_end, import_prm = extract_from_import(imp[fro.start():])
666666
# clean-up the OID
667667
if import_prm['oid']:
668-
oidstr = re.sub('\s{1,}', ' ', import_prm['oid']).strip()
668+
oidstr = re.sub(r'\s{1,}', ' ', import_prm['oid']).strip()
669669
OidDummy = OID()
670670
_path_stack(['val'])
671671
try:
@@ -688,7 +688,7 @@ def module_get_import(text=''):
688688
# get all ASN.1 objects reference before FROM
689689
obj = imp[:fro.start()].strip()
690690
# clean them up and split them to a list
691-
obj = map(strip, re.sub('\s{1,}', ' ', obj).split(','))
691+
obj = map(strip, re.sub(r'\s{1,}', ' ', obj).split(','))
692692
# remove {} at the end of parameterized objects
693693
obj = [o[:-2].strip() if o[-2:] == '{}' else o for o in obj]
694694
# fill-in the import list
@@ -739,7 +739,7 @@ def module_extract_assign(lines):
739739
Obj._text_decl = declared
740740
else:
741741
# we are on a 2nd new assignments, just returning the 1st object
742-
Obj._text_def = re.sub('\s{1,}', ' ', ' '.join(content).strip())
742+
Obj._text_def = re.sub(r'\s{1,}', ' ', ' '.join(content).strip())
743743
del lines[:line_num]
744744
asnobj_getname(Obj)
745745
asnobj_getparnum(Obj)
@@ -752,7 +752,7 @@ def module_extract_assign(lines):
752752
#
753753
# end of lines
754754
if Obj is not None:
755-
Obj._text_def = re.sub('\s{1,}', ' ', ' '.join(content).strip())
755+
Obj._text_def = re.sub(r'\s{1,}', ' ', ' '.join(content).strip())
756756
#
757757
del lines[:]
758758
asnobj_getname(Obj)
@@ -811,7 +811,7 @@ def asnobj_gettype(Obj):
811811
if not tag:
812812
raise(ASN1ProcTextErr('{0}: invalid tagging, {1}'\
813813
.format(self._name, Obj._text_def)))
814-
m = re.match('(IMPLICIT|EXPLICIT)(?:\s)', text)
814+
m = re.match(r'(IMPLICIT|EXPLICIT)(?:\s)', text)
815815
if m:
816816
text = text[m.end():].strip()
817817
# 2) try to get native type

pycrate_asn1c/utils.py

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -296,122 +296,122 @@ def pformat(obj):
296296
'SET', 'TRUE', 'UNION')
297297

298298
# basic ASN.1 tokens
299-
_RE_INTEGER = '(?:\-{0,1}0{1})|(?:\-{0,1}[1-9]{1}[0-9]{0,})'
300-
_RE_INTEGER_POS = '(?:\-{0,1}0{1})|(?:[1-9]{1}[0-9]{0,})'
301-
_RE_IDENT = '[a-z]{1,}[a-zA-Z0-9\-]{0,}'
302-
_RE_TYPEREF = '[A-Z]{1,}[a-zA-Z0-9\-]{0,}'
303-
_RE_CLASSREF = '[A-Z]{1,}[A-Z0-9\-]{0,}'
304-
_RE_WORD = '[a-zA-Z]{1,}[a-zA-Z0-9\-]{0,}'
299+
_RE_INTEGER = r'(?:\-{0,1}0{1})|(?:\-{0,1}[1-9]{1}[0-9]{0,})'
300+
_RE_INTEGER_POS = r'(?:\-{0,1}0{1})|(?:[1-9]{1}[0-9]{0,})'
301+
_RE_IDENT = r'[a-z]{1,}[a-zA-Z0-9\-]{0,}'
302+
_RE_TYPEREF = r'[A-Z]{1,}[a-zA-Z0-9\-]{0,}'
303+
_RE_CLASSREF = r'[A-Z]{1,}[A-Z0-9\-]{0,}'
304+
_RE_WORD = r'[a-zA-Z]{1,}[a-zA-Z0-9\-]{0,}'
305305

306306
# ASN.1 names
307307
SYNT_RE_WORD = re.compile(
308-
'(?:^|\s{1})(%s)' % _RE_WORD)
308+
r'(?:^|\s{1})(%s)' % _RE_WORD)
309309
SYNT_RE_IDENT = re.compile(
310-
'(?:^|\s{1})(%s)' % _RE_IDENT)
310+
r'(?:^|\s{1})(%s)' % _RE_IDENT)
311311
SYNT_RE_TYPE = re.compile(
312-
'(?:^|\s{1})(%s)(?:$|[^0-9^a-z^A-Z^\-]{1,})' % _RE_NATIVE_TYPES)
312+
r'(?:^|\s{1})(%s)(?:$|[^0-9^a-z^A-Z^\-]{1,})' % _RE_NATIVE_TYPES)
313313
SYNT_RE_TYPEREF = re.compile(
314-
'(?:^|\s{1})(%s)' % _RE_TYPEREF)
314+
r'(?:^|\s{1})(%s)' % _RE_TYPEREF)
315315
SYNT_RE_CLASSREF = re.compile(
316-
'(?:^|\s{1})(%s)' % _RE_CLASSREF)
316+
r'(?:^|\s{1})(%s)' % _RE_CLASSREF)
317317
SYNT_RE_CLASSFIELDIDENT = re.compile(
318-
'(?:^|\s{1})\&([a-zA-Z0-9\-]{1,})')
318+
r'(?:^|\s{1})\&([a-zA-Z0-9\-]{1,})')
319319
SYNT_RE_CLASSFIELDREF = re.compile(
320-
'(?:^|\s{1})((%s)\s{0,1}\.\&([a-zA-Z0-9\-]{1,}))' % _RE_CLASSREF)
320+
r'(?:^|\s{1})((%s)\s{0,1}\.\&([a-zA-Z0-9\-]{1,}))' % _RE_CLASSREF)
321321
SYNT_RE_CLASSFIELDREFINT = re.compile(
322-
'(?:^|\s{1})\&(%s)' % _RE_TYPEREF)
322+
r'(?:^|\s{1})\&(%s)' % _RE_TYPEREF)
323323
SYNT_RE_CLASSVALREF = re.compile(
324-
'(?:^|\s{1})((%s)\s{0,1}\.\&([a-zA-Z0-9\-]{1,}))' % _RE_IDENT)
324+
r'(?:^|\s{1})((%s)\s{0,1}\.\&([a-zA-Z0-9\-]{1,}))' % _RE_IDENT)
325325
SYNT_RE_CLASSINSTFIELDREF = re.compile(
326-
'(?:^|\s{1})(%s)(?:\s{0,1}\.\&(%s)){0,}' % (_RE_WORD, _RE_WORD))
326+
r'(?:^|\s{1})(%s)(?:\s{0,1}\.\&(%s)){0,}' % (_RE_WORD, _RE_WORD))
327327
SYNT_RE_IDENTEXT = re.compile(
328-
'(?:^|\s{1})((%s)\.(%s))' % (_RE_TYPEREF, _RE_IDENT))
328+
r'(?:^|\s{1})((%s)\.(%s))' % (_RE_TYPEREF, _RE_IDENT))
329329
# WNG: SYNT_RE_TYPEREF matches also SYNT_RE_CLASSREF
330330

331331
# ASN.1 expressions
332332
SYNT_RE_MODULEDEF = re.compile(
333-
'\s{1,}(DEFINITIONS)\s{1,}')
333+
r'\s{1,}(DEFINITIONS)\s{1,}')
334334
SYNT_RE_MODULEREF = re.compile(
335-
'(?:^|\s{1})(%s){1}\s{0,}(\{[\s\-a-zA-Z0-9\(\)]{1,}\}){0,1}' % _RE_TYPEREF)
335+
r'(?:^|\s{1})(%s){1}\s{0,}(\{[\s\-a-zA-Z0-9\(\)]{1,}\}){0,1}' % _RE_TYPEREF)
336336

337337
SYNT_RE_MODULEFROM = re.compile(
338-
'(?:FROM\s{1,})(%s)\s*' % _RE_TYPEREF)
338+
r'(?:FROM\s{1,})(%s)\s*' % _RE_TYPEREF)
339339
SYNT_RE_MODULEFROM_SYM = re.compile(
340-
'(%s)(?:\s*\{\s*\}){0,1}(?:\s*,|\s{1,}FROM)' % _RE_WORD)
340+
r'(%s)(?:\s*\{\s*\}){0,1}(?:\s*,|\s{1,}FROM)' % _RE_WORD)
341341
SYNT_RE_MODULEFROM_OID = re.compile(
342-
'(%s)\s*|(\{[a-zA-Z0-9\(\)\-\s]{4,}\})\s*' % _RE_IDENT)
342+
r'(%s)\s*|(\{[a-zA-Z0-9\(\)\-\s]{4,}\})\s*' % _RE_IDENT)
343343
SYNT_RE_MODULEFROM_WIT = re.compile(
344-
'WITH\s{1,}(SUCCESSORS|DESCENDANTS)\s*')
344+
r'WITH\s{1,}(SUCCESSORS|DESCENDANTS)\s*')
345345

346346
SYNT_RE_MODULEEXP = re.compile(
347-
'(?:^|\s{1})EXPORTS((.|\n)*?);')
347+
r'(?:^|\s{1})EXPORTS((.|\n)*?);')
348348
SYNT_RE_MODULEIMP = re.compile(
349-
'(?:^|\s{1})IMPORTS((.|\n)*?);')
349+
r'(?:^|\s{1})IMPORTS((.|\n)*?);')
350350
SYNT_RE_MODULEOPT = re.compile(
351-
'(?:^|\s{1})(EXPLICIT\s{1,}TAGS|IMPLICIT\s{1,}TAGS|AUTOMATIC\s{1,}TAGS)')
351+
r'(?:^|\s{1})(EXPLICIT\s{1,}TAGS|IMPLICIT\s{1,}TAGS|AUTOMATIC\s{1,}TAGS)')
352352
SYNT_RE_MODULEEXT = re.compile(
353-
'(?:^|\s{1})(EXTENSIBILITY\s{1,}IMPLIED)')
353+
r'(?:^|\s{1})(EXTENSIBILITY\s{1,}IMPLIED)')
354354
SYNT_RE_TAG = re.compile(
355-
'\[\s{0,}(UNIVERSAL|APPLICATION|PRIVATE){0,1}\s{0,}(?:(%s)|(%s))\s{0,}\]' \
355+
r'\[\s{0,}(UNIVERSAL|APPLICATION|PRIVATE){0,1}\s{0,}(?:(%s)|(%s))\s{0,}\]' \
356356
% (_RE_INTEGER_POS, _RE_IDENT))
357357
SYNT_RE_PARAM = re.compile(
358-
'(%s)(?:\s{0,}\:\s{0,}(%s|%s)){0,1}' \
358+
r'(%s)(?:\s{0,}\:\s{0,}(%s|%s)){0,1}' \
359359
% (_RE_TYPEREF, _RE_IDENT, _RE_TYPEREF))
360360
SYNT_RE_SIZEOF = re.compile(
361-
'(\({0,1}\s{0,}SIZE)|(OF)')
361+
r'(\({0,1}\s{0,}SIZE)|(OF)')
362362
SYNT_RE_INT_ID = re.compile(
363-
'(%s)\s{0,}\(\s{0,}((%s)|(%s))\s{0,}\)' \
363+
r'(%s)\s{0,}\(\s{0,}((%s)|(%s))\s{0,}\)' \
364364
% (_RE_IDENT, _RE_INTEGER, _RE_IDENT))
365365
SYNT_RE_ENUM = re.compile(
366-
'(%s|\.{3})\s{0,}(?:\(\s{0,}((%s)|(%s))\s{0,}\)){0,1}' \
366+
r'(%s|\.{3})\s{0,}(?:\(\s{0,}((%s)|(%s))\s{0,}\)){0,1}' \
367367
% (_RE_IDENT, _RE_INTEGER, _RE_IDENT))
368368
SYNT_RE_OID_COMP = re.compile(
369-
'(%s)|((%s)\s{0,}(?:\((%s)\)){0,1})' \
369+
r'(%s)|((%s)\s{0,}(?:\((%s)\)){0,1})' \
370370
% (_RE_INTEGER_POS, _RE_IDENT, _RE_INTEGER_POS))
371371
SYNT_RE_CLASSSYNTAX = re.compile(
372-
'(?:^|\s{1})((\[)|(\])|([A-Z\-]{1,})|(\&([a-zA-Z0-9\-]{1,})))')
372+
r'(?:^|\s{1})((\[)|(\])|([A-Z\-]{1,})|(\&([a-zA-Z0-9\-]{1,})))')
373373
SYNT_RE_CHOICEALT = re.compile(
374-
'(?:^|\s{1})(?:(%s)(?:\s{0,}<\s{0,})){1,}(%s)' % (_RE_IDENT, _RE_TYPEREF))
374+
r'(?:^|\s{1})(?:(%s)(?:\s{0,}<\s{0,})){1,}(%s)' % (_RE_IDENT, _RE_TYPEREF))
375375
SYNT_RE_INTVAL = re.compile(
376-
'(?:^|\s{1})(\-{0,1}[0-9]{1,})')
376+
r'(?:^|\s{1})(\-{0,1}[0-9]{1,})')
377377
SYNT_RE_BSTRING = re.compile(
378-
'(?:^|\s{1})\'([\s01]{0,})\'B')
378+
r'(?:^|\s{1})\'([\s01]{0,})\'B')
379379
SYNT_RE_HSTRING = re.compile(
380-
'(?:^|\s{1})\'([\s0-9A-F]{0,})\'H')
380+
r'(?:^|\s{1})\'([\s0-9A-F]{0,})\'H')
381381
SYNT_RE_REALNUM = re.compile(
382-
'(?:^|\s{1})' \
383-
'(\-{0,1}[0-9]{1,}){1}' \
384-
'(?:\.([0-9]{0,})){0,1}' \
385-
'(?:[eE](\-{0,1}[0-9]{1,})){0,1}')
382+
r'(?:^|\s{1})' \
383+
r'(\-{0,1}[0-9]{1,}){1}' \
384+
r'(?:\.([0-9]{0,})){0,1}' \
385+
r'(?:[eE](\-{0,1}[0-9]{1,})){0,1}')
386386
SYNT_RE_REALSEQ = re.compile(
387-
'(?:^|\s{1})' \
388-
'(?:\{\s{0,}mantissa\s{1,}(\-{0,1}[0-9]{1,})\s{0,},' \
389-
'\s{0,}base\s{1,}(2|10)\s{0,},' \
390-
'\s{0,}exponent\s{1,}(\-{0,1}[0-9]{1,})\s{0,}\})')
387+
r'(?:^|\s{1})' \
388+
r'(?:\{\s{0,}mantissa\s{1,}(\-{0,1}[0-9]{1,})\s{0,},' \
389+
r'\s{0,}base\s{1,}(2|10)\s{0,},' \
390+
r'\s{0,}exponent\s{1,}(\-{0,1}[0-9]{1,})\s{0,}\})')
391391
SYNT_RE_REALSPEC = re.compile(
392-
'(?:^|\s{1})((?:PLUS\-INFINITY)|(?:MINUS\-INFINITY)|(?:NOT-A-NUMBER))')
392+
r'(?:^|\s{1})((?:PLUS\-INFINITY)|(?:MINUS\-INFINITY)|(?:NOT-A-NUMBER))')
393393
SYNT_RE_UNIVSTR = re.compile(
394-
'(?:^|\s{1})(?:\{\s{0,}'\
395-
'([0-9]{1,3})\s{0,},\s{0,}([0-9]{1,3})\s{0,},\s{0,}'\
396-
'([0-9]{1,3})\s{0,},\s{0,}([0-9]{1,3})\s{0,}\})')
394+
r'(?:^|\s{1})(?:\{\s{0,}'\
395+
r'([0-9]{1,3})\s{0,},\s{0,}([0-9]{1,3})\s{0,},\s{0,}'\
396+
r'([0-9]{1,3})\s{0,},\s{0,}([0-9]{1,3})\s{0,}\})')
397397
SYNT_RE_TIMEUTC = re.compile(
398-
'(?:^|\s{1})' \
399-
'"([0-9]{2})([0-9]{2})([0-9]{2})' \
400-
'([0-9]{2})([0-9]{2})([0-9]{2}){0,1}' \
401-
'((?:Z)|(?:[+-]{1}[0-9]{4}))"')
398+
r'(?:^|\s{1})' \
399+
r'"([0-9]{2})([0-9]{2})([0-9]{2})' \
400+
r'([0-9]{2})([0-9]{2})([0-9]{2}){0,1}' \
401+
r'((?:Z)|(?:[+-]{1}[0-9]{4}))"')
402402
SYNT_RE_TIMEGENE = re.compile(
403-
'(?:^|\s{1})' \
404-
'"([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})' \
405-
'(?:([0-9]{2})([0-9]{2}){0,1}){0,1}' \
406-
'(?:(?:\.|,)([0-9]{1,})){0,1}' \
407-
'((?:Z)|(?:[+-](?:[0-9]{2}){0,2})){0,1}"')
403+
r'(?:^|\s{1})' \
404+
r'"([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})' \
405+
r'(?:([0-9]{2})([0-9]{2}){0,1}){0,1}' \
406+
r'(?:(?:\.|,)([0-9]{1,})){0,1}' \
407+
r'((?:Z)|(?:[+-](?:[0-9]{2}){0,2})){0,1}"')
408408
SYNT_RE_CONST_DISPATCH = re.compile(
409-
'(?:^|\s{1})(INCLUDES)|(SIZE)|(FROM)|(WITH COMPONENTS)|(WITH COMPONENT)|' \
410-
'(PATTERN)|(SETTINGS)|(CONTAINING)|(ENCODED BY)|(CONSTRAINED BY)')
409+
r'(?:^|\s{1})(INCLUDES)|(SIZE)|(FROM)|(WITH COMPONENTS)|(WITH COMPONENT)|' \
410+
r'(PATTERN)|(SETTINGS)|(CONTAINING)|(ENCODED BY)|(CONSTRAINED BY)')
411411
SYNT_RE_CONST_EXT = re.compile(
412-
',\s{0,}\.\.\.')
412+
r',\s{0,}\.\.\.')
413413
SYNT_RE_GROUPVERS = re.compile(
414-
'(?:^|\s{1})[0-9]{1,}\s{0,1}\:')
414+
r'(?:^|\s{1})[0-9]{1,}\s{0,1}\:')
415415

416416
def match_typeref(text):
417417
m = SYNT_RE_TYPEREF.match(text)
@@ -720,7 +720,7 @@ def extract_charstr(text=''):
720720
# no end-of-charstr found
721721
return text, None
722722
else:
723-
return '', re.subn('\s{0,}\n\s{0,}', '', text[1:-1])[0]
723+
return '', re.subn(r'\s{0,}\n\s{0,}', '', text[1:-1])[0]
724724

725725
# 2) finding a double-quote
726726
if text[cur:1+cur] == '"':
@@ -737,7 +737,7 @@ def extract_charstr(text=''):
737737
else:
738738
# end of charstr
739739
return text[1+cur:].strip(), \
740-
re.subn('\s{0,}\n\s{0,}', '', text[1:cur])[0]
740+
re.subn(r'\s{0,}\n\s{0,}', '', text[1:cur])[0]
741741
else:
742742
# 2.2) escape cursor not set
743743
if text[1+cur:2+cur] == '"':
@@ -746,7 +746,7 @@ def extract_charstr(text=''):
746746
else:
747747
# end of charstr
748748
return text[1+cur:].strip(), \
749-
re.subn('\s{0,}\n\s{0,}', '', text[1:cur])[0]
749+
re.subn(r'\s{0,}\n\s{0,}', '', text[1:cur])[0]
750750

751751

752752
def extract_multi(text=''):

0 commit comments

Comments
 (0)