Mercurial > cpython-lru_cache-weakref
annotate Tools/scripts/cvsfiles.py @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | 981fff7363b9 |
| children | 6b18a095c2e7 |
| rev | line source |
|---|---|
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
|
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
3 """Print a list of files that are mentioned in CVS directories. |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
4 |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
5 Usage: cvsfiles.py [-n file] [directory] ... |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
6 |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
7 If the '-n file' option is given, only files under CVS that are newer |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
8 than the given file are printed; by default, all files under CVS are |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
9 printed. As a special case, if a file does not exist, it is always |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
10 printed. |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
11 """ |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 |
|
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 import os |
|
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 import sys |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
15 import stat |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
16 import getopt |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
18 cutofftime = 0 |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
19 |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 def main(): |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
21 try: |
| 7735 | 22 opts, args = getopt.getopt(sys.argv[1:], "n:") |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
23 except getopt.error, msg: |
| 7735 | 24 print msg |
| 25 print __doc__, | |
| 26 return 1 | |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
27 global cutofftime |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
28 newerfile = None |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
29 for o, a in opts: |
| 7735 | 30 if o == '-n': |
| 31 cutofftime = getmtime(a) | |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 if args: |
| 7735 | 33 for arg in args: |
| 34 process(arg) | |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 else: |
| 7735 | 36 process(".") |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 |
|
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 def process(dir): |
|
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 cvsdir = 0 |
|
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 subdirs = [] |
|
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 names = os.listdir(dir) |
|
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 for name in names: |
| 7735 | 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) | |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 if cvsdir: |
| 7735 | 51 entries = os.path.join(cvsdir, "Entries") |
| 52 for e in open(entries).readlines(): | |
|
25219
8a7a2f1f88f0
Apply diff2.txt from SF patch http://www.python.org/sf/572113
Walter Dörwald <walter@livinglogic.de>
parents:
7735
diff
changeset
|
53 words = e.split('/') |
| 7735 | 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 | |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 for sub in subdirs: |
| 7735 | 62 process(sub) |
|
6033
ac7554f29313
Print a list of files under CVS.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
64 def getmtime(filename): |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
65 try: |
| 7735 | 66 st = os.stat(filename) |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
67 except os.error: |
| 7735 | 68 return 0 |
|
6642
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
69 return st[stat.ST_MTIME] |
|
2518ac9251f0
Added "-n file" option to only print files newer than the given file.
Guido van Rossum <guido@python.org>
parents:
6320
diff
changeset
|
70 |
|
33074
981fff7363b9
[Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents:
25219
diff
changeset
|
71 if __name__ == '__main__': |
|
981fff7363b9
[Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents:
25219
diff
changeset
|
72 main() |
