File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /usr/bin/env python
22
3- """Create a list of files that are mentioned in CVS directories."""
3+ """Print a list of files that are mentioned in CVS directories.
4+
5+ Usage: cvsfiles.py [-n file] [directory] ...
6+
7+ If the '-n file' option is given, only files under CVS that are newer
8+ than the given file are printed; by default, all files under CVS are
9+ printed. As a special case, if a file does not exist, it is always
10+ printed.
11+ """
412
513import os
614import sys
15+ import stat
16+ import getopt
717import string
818
19+ cutofftime = 0
20+
921def main ():
10- args = sys .argv [1 :]
22+ try :
23+ opts , args = getopt .getopt (sys .argv [1 :], "n:" )
24+ except getopt .error , msg :
25+ print msg
26+ print __doc__ ,
27+ return 1
28+ global cutofftime
29+ newerfile = None
30+ for o , a in opts :
31+ if o == '-n' :
32+ cutofftime = getmtime (a )
1133 if args :
1234 for arg in args :
1335 process (arg )
@@ -32,8 +54,19 @@ def process(dir):
3254 words = string .split (e , '/' )
3355 if words [0 ] == '' and words [1 :]:
3456 name = words [1 ]
35- print os .path .join (dir , name )
57+ fullname = os .path .join (dir , name )
58+ if cutofftime and getmtime (fullname ) <= cutofftime :
59+ pass
60+ else :
61+ print fullname
3662 for sub in subdirs :
3763 process (sub )
3864
39- main ()
65+ def getmtime (filename ):
66+ try :
67+ st = os .stat (filename )
68+ except os .error :
69+ return 0
70+ return st [stat .ST_MTIME ]
71+
72+ sys .exit (main ())
You can’t perform that action at this time.
0 commit comments