parent
5694f12910
commit
0646f6c9da
|
@ -873,8 +873,14 @@ if __name__ == "__main__":
|
|||
i += 1
|
||||
auxname = '%s/%d' % (name, i)
|
||||
name = auxname
|
||||
b = f(path, nl, name, opts.binary)
|
||||
b.open()
|
||||
|
||||
try:
|
||||
b = f(path, nl, name, opts.binary)
|
||||
b.open()
|
||||
except buffer2.BinaryDataException, e:
|
||||
b = f(path, nl, name, True)
|
||||
b.open()
|
||||
|
||||
buffers.append(b)
|
||||
paths.add(path)
|
||||
names.add(name)
|
||||
|
|
11
buffer2.py
11
buffer2.py
|
@ -354,6 +354,9 @@ class ConsoleBuffer(Buffer):
|
|||
def readonly(self):
|
||||
return True
|
||||
|
||||
class BinaryDataException(Exception):
|
||||
pass
|
||||
|
||||
class FileBuffer(Buffer):
|
||||
btype = 'file'
|
||||
def __init__(self, path, nl='\n', name=None):
|
||||
|
@ -417,12 +420,12 @@ class FileBuffer(Buffer):
|
|||
self.store_checksum(data)
|
||||
else:
|
||||
data = ''
|
||||
for i in range(0, min(len(data), 8)):
|
||||
if ord(data[i]) > 127:
|
||||
raise Exception, "editing binary files is not supported"
|
||||
data = self.read_filter(data)
|
||||
#FIXME: this is horrible...but maybe not as horrible as using tabs??
|
||||
data = data.replace("\t", " ")
|
||||
for i in range(0, min(len(data), 8)):
|
||||
if data[i] not in string.printable:
|
||||
raise BinaryDataException, "binary files are not supported"
|
||||
#FIXME: this is horrible...but maybe not as horrible as using tabs??
|
||||
return data
|
||||
def open(self):
|
||||
data = self.read()
|
||||
|
|
Loading…
Reference in New Issue