Show More
@@ -869,6 +869,34 b' else:' | |||||
869 | st = fstat(f) |
|
869 | st = fstat(f) | |
870 | return st.st_uid == os.getuid() |
|
870 | return st.st_uid == os.getuid() | |
871 |
|
871 | |||
|
872 | def _buildencodefun(): | |||
|
873 | e = '_' | |||
|
874 | win_reserved = [ord(x) for x in '|\?*<":>+[]'] | |||
|
875 | cmap = dict([ (chr(x), chr(x)) for x in xrange(127) ]) | |||
|
876 | for x in (range(32) + range(126, 256) + win_reserved): | |||
|
877 | cmap[chr(x)] = "~%02x" % x | |||
|
878 | for x in range(ord("A"), ord("Z")+1) + [ord(e)]: | |||
|
879 | cmap[chr(x)] = e + chr(x).lower() | |||
|
880 | dmap = {} | |||
|
881 | for k, v in cmap.iteritems(): | |||
|
882 | dmap[v] = k | |||
|
883 | def decode(s): | |||
|
884 | i = 0 | |||
|
885 | while i < len(s): | |||
|
886 | for l in xrange(1, 4): | |||
|
887 | try: | |||
|
888 | yield dmap[s[i:i+l]] | |||
|
889 | i += l | |||
|
890 | break | |||
|
891 | except KeyError: | |||
|
892 | pass | |||
|
893 | else: | |||
|
894 | raise KeyError | |||
|
895 | return (lambda s: "".join([cmap[c] for c in s]), | |||
|
896 | lambda s: "".join(list(decode(s)))) | |||
|
897 | ||||
|
898 | encodefilename, decodefilename = _buildencodefun() | |||
|
899 | ||||
872 |
|
900 | |||
873 | def opener(base, audit=True): |
|
901 | def opener(base, audit=True): | |
874 | """ |
|
902 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now