Mercurial > cpython-lru_cache-weakref
annotate Demo/scripts/mkrcs.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 487280cf71b9 |
| children | 7d16b42fcdbd |
| rev | line source |
|---|---|
|
4573
73758db2f464
/usr/local/bin/python -> /usr/bin/env python
Guido van Rossum <guido@python.org>
parents:
1506
diff
changeset
|
1 #! /usr/bin/env python |
| 875 | 2 |
| 3 # A rather specialized script to make sure that a symbolic link named | |
| 4 # RCS exists pointing to a real RCS directory in a parallel tree | |
| 5 # referenced as RCStree in an ancestor directory. | |
| 6 # (I use this because I like my RCS files to reside on a physically | |
| 7 # different machine). | |
| 8 | |
| 9 import os | |
| 10 | |
| 11 def main(): | |
|
32735
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
12 rcstree = 'RCStree' |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
13 rcs = 'RCS' |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
14 if os.path.islink(rcs): |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
15 print '%r is a symlink to %r' % (rcs, os.readlink(rcs)) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
16 return |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
17 if os.path.isdir(rcs): |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
18 print '%r is an ordinary directory' % (rcs,) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
19 return |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
20 if os.path.exists(rcs): |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
21 print '%r is a file?!?!' % (rcs,) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
22 return |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
23 # |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
24 p = os.getcwd() |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
25 up = '' |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
26 down = '' |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
27 # Invariants: |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
28 # (1) join(p, down) is the current directory |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
29 # (2) up is the same directory as p |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
30 # Ergo: |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
31 # (3) join(up, down) is the current directory |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
32 #print 'p =', repr(p) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
33 while not os.path.isdir(os.path.join(p, rcstree)): |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
34 head, tail = os.path.split(p) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
35 #print 'head = %r; tail = %r' % (head, tail) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
36 if not tail: |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
37 print 'Sorry, no ancestor dir contains %r' % (rcstree,) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
38 return |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
39 p = head |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
40 up = os.path.join(os.pardir, up) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
41 down = os.path.join(tail, down) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
42 #print 'p = %r; up = %r; down = %r' % (p, up, down) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
43 there = os.path.join(up, rcstree) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
44 there = os.path.join(there, down) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
45 there = os.path.join(there, rcs) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
46 if os.path.isdir(there): |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
47 print '%r already exists' % (there, ) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
48 else: |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
49 print 'making %r' % (there,) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
50 makedirs(there) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
51 print 'making symlink %r -> %r' % (rcs, there) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
52 os.symlink(there, rcs) |
| 875 | 53 |
| 54 def makedirs(p): | |
|
32735
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
55 if not os.path.isdir(p): |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
56 head, tail = os.path.split(p) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
57 makedirs(head) |
|
2bc66f1df7cc
Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
58 os.mkdir(p, 0777) |
| 875 | 59 |
|
33456
487280cf71b9
Add 'if __name__ == "__main__":' to files already as a usable as a module.
Johannes Gijsbers <jlg@dds.nl>
parents:
32735
diff
changeset
|
60 if __name__ == "__main__": |
|
487280cf71b9
Add 'if __name__ == "__main__":' to files already as a usable as a module.
Johannes Gijsbers <jlg@dds.nl>
parents:
32735
diff
changeset
|
61 main() |
