22 from atlas
import codecs
29 """client for reading/writing files: currently only read support"""
30 def __init__(self, name, mode="r", codec_id=None):
32 self.
fpfp = open(name, mode)
41 self.
codec_idcodec_id = codecs.get_default_codec().id
45 def send_string(self, str):
46 if self.
modemode==
"w":
52 def operation_received(self, op):
55 def read_object(self):
58 return self.
objectsobjects.pop(0)
59 data = self.
fpfp.read(buf_size)
62 self.
bridgebridge.process_string(data)
64 def write_object(self, obj):
65 self.
bridgebridge.process_operation(obj)
67 def check_negotiation_ok(self):
68 if not self.
bridgebridge.codec:
69 raise IOError(
"no codec negotiated in file %s" % self.
namename)
71 def read_all_as_list(self):
80 def read_all_as_dict(self):
89 def read_and_analyse_all(self):
105 return f.read_all_as_list()
107 def read_file_as_dict(name):
109 return f.read_all_as_dict()
111 def read_and_analyse(name):
113 return f.read_and_analyse_all()
115 def write_file(objects, name, encoding=None):
116 f =
File(name,
"w", encoding)
121 def translate(input, output, output_encoding=None):
122 objects = read_file(input)
123 write_file(objects, output, output_encoding)
def find_parents_children_objects(objects)
def check_negotiation_ok(self)