diff options
author | Guido van Rossum <guido@python.org> | 1997-11-24 23:49:35 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-11-24 23:49:35 (GMT) |
commit | ca83f018e7d5c74607cfcdbb9e5e808ad240af8d (patch) | |
tree | 89cb7ef7e8696710b34aa7caf31c8b1600e9200b /Tools | |
parent | e2d4dd194b67800f67c5b333fc3d891eeed09d09 (diff) | |
download | cpython-ca83f018e7d5c74607cfcdbb9e5e808ad240af8d.zip cpython-ca83f018e7d5c74607cfcdbb9e5e808ad240af8d.tar.gz cpython-ca83f018e7d5c74607cfcdbb9e5e808ad240af8d.tar.bz2 |
Added "-n file" option to only print files newer than the given file.
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/scripts/cvsfiles.py | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/Tools/scripts/cvsfiles.py b/Tools/scripts/cvsfiles.py index 21e72ee..5b691f6 100755 --- a/Tools/scripts/cvsfiles.py +++ b/Tools/scripts/cvsfiles.py @@ -1,13 +1,35 @@ #! /usr/bin/env python -"""Create a list of files that are mentioned in CVS directories.""" +"""Print a list of files that are mentioned in CVS directories. + +Usage: cvsfiles.py [-n file] [directory] ... + +If the '-n file' option is given, only files under CVS that are newer +than the given file are printed; by default, all files under CVS are +printed. As a special case, if a file does not exist, it is always +printed. +""" import os import sys +import stat +import getopt import string +cutofftime = 0 + def main(): - args = sys.argv[1:] + try: + opts, args = getopt.getopt(sys.argv[1:], "n:") + except getopt.error, msg: + print msg + print __doc__, + return 1 + global cutofftime + newerfile = None + for o, a in opts: + if o == '-n': + cutofftime = getmtime(a) if args: for arg in args: process(arg) @@ -32,8 +54,19 @@ def process(dir): words = string.split(e, '/') if words[0] == '' and words[1:]: name = words[1] - print os.path.join(dir, name) + fullname = os.path.join(dir, name) + if cutofftime and getmtime(fullname) <= cutofftime: + pass + else: + print fullname for sub in subdirs: process(sub) -main() +def getmtime(filename): + try: + st = os.stat(filename) + except os.error: + return 0 + return st[stat.ST_MTIME] + +sys.exit(main()) |