|
28 | 28 | and for a file with a binary mime-type property: |
29 | 29 |
|
30 | 30 | svn: File 'Lib\test\test_pep263.py' has binary mime type property |
31 | | -
|
32 | | -TODO: This is slow, and especially on Windows, because it invokes a new svn |
33 | | -command-line operation for every file with the right extension. |
34 | 31 | """ |
35 | 32 |
|
36 | 33 | import re |
37 | 34 | import os |
38 | 35 |
|
| 36 | +def proplist(root, fn): |
| 37 | + "Return a list of property names for file fn in directory root" |
| 38 | + path = os.path.join(root, ".svn", "props", fn+".svn-work") |
| 39 | + try: |
| 40 | + f = open(path) |
| 41 | + except IOError: |
| 42 | + # no properties file: not under version control |
| 43 | + return [] |
| 44 | + result = [] |
| 45 | + while 1: |
| 46 | + # key-value pairs, of the form |
| 47 | + # K <length> |
| 48 | + # <keyname>NL |
| 49 | + # V length |
| 50 | + # <value>NL |
| 51 | + # END |
| 52 | + line = f.readline() |
| 53 | + if line.startswith("END"): |
| 54 | + break |
| 55 | + assert line.startswith("K ") |
| 56 | + L = int(line.split()[1]) |
| 57 | + key = f.read(L) |
| 58 | + result.append(key) |
| 59 | + f.readline() |
| 60 | + line = f.readline() |
| 61 | + assert line.startswith("V ") |
| 62 | + L = int(line.split()[1]) |
| 63 | + value = f.read(L) |
| 64 | + f.readline() |
| 65 | + f.close() |
| 66 | + return result |
| 67 | + |
39 | 68 | possible_text_file = re.compile(r"\.([hc]|py|txt)$").search |
40 | 69 |
|
41 | 70 | for root, dirs, files in os.walk('.'): |
42 | 71 | if '.svn' in dirs: |
43 | 72 | dirs.remove('.svn') |
44 | 73 | for fn in files: |
45 | 74 | if possible_text_file(fn): |
46 | | - path = os.path.join(root, fn) |
47 | | - p = os.popen('svn proplist "%s"' % path) |
48 | | - guts = p.read() |
49 | | - p.close() |
50 | | - if 'eol-style' not in guts: |
| 75 | + if 'svn:eol-style' not in proplist(root, fn): |
| 76 | + path = os.path.join(root, fn) |
51 | 77 | os.system('svn propset svn:eol-style native "%s"' % path) |
0 commit comments