-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvnmime.py
47 lines (42 loc) · 1.28 KB
/
svnmime.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# NB, this wouldn't be needed if everyone had .subversion/config
# configured to automatically set mime types
# http://code.google.com/p/support/wiki/FAQ
import os
import sys
types_map = {
'ai': 'application/postscript',
'coverage': 'text/plain',
'css': 'text/css',
'eps': 'application/postscript',
'exe': 'application/octet-stream',
'errs': 'text/plain',
'gif': 'image/gif',
'htm': 'text/html',
'html': 'text/html',
'jpeg': 'image/jpeg',
'jpg': 'image/jpeg',
'js': 'application/x-javascript',
'pbm': 'image/x-portable-bitmap',
'pdf': 'application/pdf',
'pgm': 'image/x-portable-graymap',
'pnm': 'image/x-portable-anymap',
'png': 'image/png',
'ppm': 'image/x-portable-pixmap',
'py': 'text/x-python',
'ps': 'application/postscript',
'rst': 'text/plain',
'tex': 'application/x-tex',
'txt': 'text/plain',
'xml': 'text/xml',
'zip': 'application/zip',
}
def usage():
exit("Usage: svnmime files")
for file in sys.argv[1:]:
if "." in file:
extension = file.rsplit('.', 1)[1]
if extension in types_map:
os.system("svn propset svn:mime-type %s %s" % (types_map[extension], file))
else:
print "Unrecognized extension", extension