summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2003-02-06 19:55:35 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2003-02-06 19:55:35 (GMT)
commitd683504b85206334aba32e8706ca6cb15b3efbf7 (patch)
tree8ebbb3c7ce8bf30d586334b64126dae3d8680db4 /Tools
parentc7557589063d07ecf8a65e88e6e396f0f750821b (diff)
downloadcpython-d683504b85206334aba32e8706ca6cb15b3efbf7.zip
cpython-d683504b85206334aba32e8706ca6cb15b3efbf7.tar.gz
cpython-d683504b85206334aba32e8706ca6cb15b3efbf7.tar.bz2
Use new name for GetoptError, and pass it two arguments
Use re module instead of regex
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/findlinksto.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Tools/scripts/findlinksto.py b/Tools/scripts/findlinksto.py
index e4731a5..00d4a18 100755
--- a/Tools/scripts/findlinksto.py
+++ b/Tools/scripts/findlinksto.py
@@ -6,21 +6,21 @@
import os
import sys
-import regex
+import re
import getopt
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], '')
if len(args) < 2:
- raise getopt.error, 'not enough arguments'
- except getopt.error, msg:
+ raise getopt.GetoptError('not enough arguments', None)
+ except getopt.GetoptError, msg:
sys.stdout = sys.stderr
print msg
print 'usage: findlinksto pattern directory ...'
sys.exit(2)
pat, dirs = args[0], args[1:]
- prog = regex.compile(pat)
+ prog = re.compile(pat)
for dirname in dirs:
os.path.walk(dirname, visit, prog)
@@ -34,7 +34,7 @@ def visit(prog, dirname, names):
name = os.path.join(dirname, name)
try:
linkto = os.readlink(name)
- if prog.search(linkto) >= 0:
+ if prog.search(linkto) is not None:
print name, '->', linkto
except os.error:
pass