|
Last change
on this file was 2, checked in by Yuri Dario, 15 years ago |
|
Initial import for vendor code.
|
-
Property svn:eol-style
set to
native
|
|
File size:
1.7 KB
|
| Line | |
|---|
| 1 | #! /usr/bin/env python
|
|---|
| 2 |
|
|---|
| 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 | """
|
|---|
| 12 |
|
|---|
| 13 | import os
|
|---|
| 14 | import sys
|
|---|
| 15 | import stat
|
|---|
| 16 | import getopt
|
|---|
| 17 |
|
|---|
| 18 | cutofftime = 0
|
|---|
| 19 |
|
|---|
| 20 | def main():
|
|---|
| 21 | try:
|
|---|
| 22 | opts, args = getopt.getopt(sys.argv[1:], "n:")
|
|---|
| 23 | except getopt.error, msg:
|
|---|
| 24 | print msg
|
|---|
| 25 | print __doc__,
|
|---|
| 26 | return 1
|
|---|
| 27 | global cutofftime
|
|---|
| 28 | newerfile = None
|
|---|
| 29 | for o, a in opts:
|
|---|
| 30 | if o == '-n':
|
|---|
| 31 | cutofftime = getmtime(a)
|
|---|
| 32 | if args:
|
|---|
| 33 | for arg in args:
|
|---|
| 34 | process(arg)
|
|---|
| 35 | else:
|
|---|
| 36 | process(".")
|
|---|
| 37 |
|
|---|
| 38 | def process(dir):
|
|---|
| 39 | cvsdir = 0
|
|---|
| 40 | subdirs = []
|
|---|
| 41 | names = os.listdir(dir)
|
|---|
| 42 | for name in names:
|
|---|
| 43 | fullname = os.path.join(dir, name)
|
|---|
| 44 | if name == "CVS":
|
|---|
| 45 | cvsdir = fullname
|
|---|
| 46 | else:
|
|---|
| 47 | if os.path.isdir(fullname):
|
|---|
| 48 | if not os.path.islink(fullname):
|
|---|
| 49 | subdirs.append(fullname)
|
|---|
| 50 | if cvsdir:
|
|---|
| 51 | entries = os.path.join(cvsdir, "Entries")
|
|---|
| 52 | for e in open(entries).readlines():
|
|---|
| 53 | words = e.split('/')
|
|---|
| 54 | if words[0] == '' and words[1:]:
|
|---|
| 55 | name = words[1]
|
|---|
| 56 | fullname = os.path.join(dir, name)
|
|---|
| 57 | if cutofftime and getmtime(fullname) <= cutofftime:
|
|---|
| 58 | pass
|
|---|
| 59 | else:
|
|---|
| 60 | print fullname
|
|---|
| 61 | for sub in subdirs:
|
|---|
| 62 | process(sub)
|
|---|
| 63 |
|
|---|
| 64 | def getmtime(filename):
|
|---|
| 65 | try:
|
|---|
| 66 | st = os.stat(filename)
|
|---|
| 67 | except os.error:
|
|---|
| 68 | return 0
|
|---|
| 69 | return st[stat.ST_MTIME]
|
|---|
| 70 |
|
|---|
| 71 | if __name__ == '__main__':
|
|---|
| 72 | main()
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.