Mercurial > cpython-lru_cache-weakref
annotate Tools/scripts/cvsfiles.py @ 58689:514b56efd89a 3.1
Merged revisions 77962 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r77962 | r.david.murray | 2010-02-04 11:41:57 -0500 (Thu, 04 Feb 2010) | 17 lines
Merged revisions 77943,77959-77960 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77943 | r.david.murray | 2010-02-03 08:36:23 -0500 (Wed, 03 Feb 2010) | 2 lines
Explicitly mention the default value for formatdate's usegmt parameter.
........
r77959 | nick.coghlan | 2010-02-04 07:43:58 -0500 (Thu, 04 Feb 2010) | 1 line
Issue 6760: Clarify args handling for subprocess.Popen. Patch by Chris Rebert
........
r77960 | r.david.murray | 2010-02-04 11:33:31 -0500 (Thu, 04 Feb 2010) | 2 lines
Add Chris Rebert to ACKS for issue 6760 Popen doc improvements.
........
................
| author | R. David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Thu, 04 Feb 2010 16:44:31 +0000 |
| parents | 46625e6122e9 |
| children | fcfe324663a6 |
| 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:") |
|
40587
6b18a095c2e7
SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents:
33074
diff
changeset
|
23 except getopt.error as msg: |
|
42427
46625e6122e9
Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents:
40587
diff
changeset
|
24 print(msg) |
|
46625e6122e9
Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents:
40587
diff
changeset
|
25 print(__doc__, end=' ') |
| 7735 | 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: | |
|
42427
46625e6122e9
Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents:
40587
diff
changeset
|
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() |
