def read_document(file_obj): """use FileDocument to load document from 'file_obj'""" from solipsis.services.profile.file_document import FileDocument encoding = load_encoding(file_obj) config = CustomConfigParser(encoding) config.readfp(file_obj) file_obj.close() doc = FileDocument() doc.encoding = encoding doc.config = config return doc
def read_document(stream): """use FileDocument to load document""" from solipsis.services.profile.file_document import FileDocument encoding = stream.readline()[1:] config = CustomConfigParser(encoding) config.readfp(stream) stream.close() try: pseudo = unicode(config.get(SECTION_PERSONAL, "pseudo", "Anonymous"), ENCODING) except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): print "Could not retreive pseudo" pseudo = u"Anonymous" doc = FileDocument(pseudo) doc.encoding = encoding doc.config = config return doc