summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-08-31 10:53:53 (GMT)
committerGuido van Rossum <guido@python.org>1992-08-31 10:53:53 (GMT)
commitf2e1cfb8f36c2385e16e0816a8e14e19a0cdcef1 (patch)
treee4bc49273fd8b0edc47022a5a52aae7d8fdeec86 /Tools
parenta93265a66689729a293aac07d3984203142ff90f (diff)
downloadcpython-f2e1cfb8f36c2385e16e0816a8e14e19a0cdcef1.zip
cpython-f2e1cfb8f36c2385e16e0816a8e14e19a0cdcef1.tar.gz
cpython-f2e1cfb8f36c2385e16e0816a8e14e19a0cdcef1.tar.bz2
Use regex and don't use path
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/ptags.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/Tools/scripts/ptags.py b/Tools/scripts/ptags.py
index fdf7bd1..e0159ce 100755
--- a/Tools/scripts/ptags.py
+++ b/Tools/scripts/ptags.py
@@ -11,8 +11,8 @@
# No warnings about duplicate tags.
import sys
-import regexp
-import path
+import regex
+import os
tags = [] # Modified global variable!
@@ -24,7 +24,9 @@ def main():
tags.sort()
for s in tags: fp.write(s)
-matcher = regexp.compile('^[ \t]*(def|class)[ \t]+([a-zA-Z0-9_]+)[ \t]*\(')
+
+expr = '^[ \t]*\(def\|class\)[ \t]+\([a-zA-Z0-9_]+\)[ \t]*[:(]'
+matcher = regex.compile(expr)
def treat_file(file):
try:
@@ -32,16 +34,15 @@ def treat_file(file):
except:
print 'Cannot open', file
return
- base = path.basename(file)
+ base = os.path.basename(file)
if base[-3:] == '.py': base = base[:-3]
s = base + '\t' + file + '\t' + '1\n'
tags.append(s)
while 1:
line = fp.readline()
if not line: break
- res = matcher.exec(line)
- if res:
- (a, b), (a1, b1), (a2, b2) = res
+ if matcher.search(line) >= 0:
+ (a, b), (a1, b1), (a2, b2) = matcher.regs[:3]
name = line[a2:b2]
s = name + '\t' + file + '\t/^' + line[a:b] + '/\n'
tags.append(s)