def to_ContentObject(self): """Returns 2dx as a ContentObject. It's .io contents are cStringIO buffer. """ sio = self.to_StringIO() resref = self.co.resref res_type = 2017 sio.seek(0, os.SEEK_END) size = sio.tell() return ContentObject(resref, res_type, sio, 0, size)
def __init__(self, source): if isinstance(source, str): source = ContentObject.from_file(source) elif not isinstance(source, ContentObject): raise ValueError("Unsupported source type %s!" % type(source)) self.columns = [] self.rows = [] self.max = None self.newline = "\n" self.tlk_columns = None self.tlk_offset = None self.co = source self.description = None self.parse(source.get('r'))
def __init__(self, source): if isinstance(source, str): source = ContentObject.from_file(source) elif not isinstance(source, ContentObject): raise ValueError("Unsupported source type %s!" % type(source)) self.columns = [] self.rows = [] self.max = None self.newline = "\n" self.default = None self.co = source data = source.get() if not isinstance(data, str): data = data.decode(get_encoding()) self.parse(data)