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

Skip to content

Commit d683504

Browse files
committed
Use new name for GetoptError, and pass it two arguments
Use re module instead of regex
1 parent c755758 commit d683504

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Tools/scripts/findlinksto.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66

77
import os
88
import sys
9-
import regex
9+
import re
1010
import getopt
1111

1212
def main():
1313
try:
1414
opts, args = getopt.getopt(sys.argv[1:], '')
1515
if len(args) < 2:
16-
raise getopt.error, 'not enough arguments'
17-
except getopt.error, msg:
16+
raise getopt.GetoptError('not enough arguments', None)
17+
except getopt.GetoptError, msg:
1818
sys.stdout = sys.stderr
1919
print msg
2020
print 'usage: findlinksto pattern directory ...'
2121
sys.exit(2)
2222
pat, dirs = args[0], args[1:]
23-
prog = regex.compile(pat)
23+
prog = re.compile(pat)
2424
for dirname in dirs:
2525
os.path.walk(dirname, visit, prog)
2626

@@ -34,7 +34,7 @@ def visit(prog, dirname, names):
3434
name = os.path.join(dirname, name)
3535
try:
3636
linkto = os.readlink(name)
37-
if prog.search(linkto) >= 0:
37+
if prog.search(linkto) is not None:
3838
print name, '->', linkto
3939
except os.error:
4040
pass

0 commit comments

Comments
 (0)