Back to index

python3.2  3.2.2
Functions
findlinksto Namespace Reference

Functions

def main
def visit

Function Documentation

Definition at line 12 of file findlinksto.py.

00012 
00013 def main():
00014     try:
00015         opts, args = getopt.getopt(sys.argv[1:], '')
00016         if len(args) < 2:
00017             raise getopt.GetoptError('not enough arguments', None)
00018     except getopt.GetoptError as msg:
00019         sys.stdout = sys.stderr
00020         print(msg)
00021         print('usage: findlinksto pattern directory ...')
00022         sys.exit(2)
00023     pat, dirs = args[0], args[1:]
00024     prog = re.compile(pat)
00025     for dirname in dirs:
00026         os.walk(dirname, visit, prog)

Here is the call graph for this function:

Here is the caller graph for this function:

def findlinksto.visit (   prog,
  dirname,
  names 
)

Definition at line 27 of file findlinksto.py.

00027 
00028 def visit(prog, dirname, names):
00029     if os.path.islink(dirname):
00030         names[:] = []
00031         return
00032     if os.path.ismount(dirname):
00033         print('descend into', dirname)
00034     for name in names:
00035         name = os.path.join(dirname, name)
00036         try:
00037             linkto = os.readlink(name)
00038             if prog.search(linkto) is not None:
00039                 print(name, '->', linkto)
00040         except os.error:
00041             pass

Here is the call graph for this function: