Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0cc1945

Browse files
committed
Use regex instead of regexp
1 parent f2e1cfb commit 0cc1945

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Tools/scripts/eptags.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
# No warnings about duplicate tags.
1111

1212
import sys
13-
import regexp
13+
import regex
1414

1515
def main():
1616
outfp = open('TAGS', 'w')
1717
args = sys.argv[1:]
1818
for file in args:
1919
treat_file(file, outfp)
2020

21-
expr = '^[ \t]*(def|class)[ \t]+([a-zA-Z0-9_]+)[ \t]*[:(]'
22-
matcher = regexp.compile(expr).match
21+
expr = '^[ \t]*\(def\|class\)[ \t]+\([a-zA-Z0-9_]+\)[ \t]*[:(]'
22+
matcher = regex.compile(expr)
2323

2424
def treat_file(file, outfp):
2525
try:
@@ -35,9 +35,8 @@ def treat_file(file, outfp):
3535
line = fp.readline()
3636
if not line: break
3737
lineno = lineno + 1
38-
res = matcher(line)
39-
if res:
40-
(a, b), (a1, b1), (a2, b2) = res
38+
if matcher.search(line) >= 0:
39+
(a, b), (a1, b1), (a2, b2) = matcher.regs[:3]
4140
name = line[a2:b2]
4241
pat = line[a:b]
4342
tag = pat + '\177' + `lineno` + ',' + `charno` + '\n'

0 commit comments

Comments
 (0)