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