return rv elif subfix == "_s": if value is None: return '' return value else: if value is None: return '' return value def get_dict(element): rst = {} children = element.getchildren() for i in children: rst[i.tag] = i.text return rst if __name__ == "__main__": import time path = "E://ChineseData.xml" o = read_cfg(path) print o print len(o) stream = StringIO() h = Hmf() h.write_object(o, stream) stream.seek(0) fd = open("E://out.hmf", "wb") fd.write(stream.read()) fd.close()
base_path = sys.argv[1] out_path = sys.argv[2] def_path = sys.argv[3] def_out_path = sys.argv[4] files = dircache.listdir(unicode(base_path, "utf-8")) for name in files: if name == '.svn': continue if name[-4:] != '.xml': continue print name r = read_cfg(unicode(base_path, "utf-8") + name) stream = StringIO() #print r h = Hmf() h.write_object(r, stream) stream.seek(0) fd = open(out_path + name[:-4] + '.xml', "wb") fd.write(stream.read()) fd.close() files = dircache.listdir(unicode(def_path, "utf-8")) for name in files: if name == '.svn': continue if name[-4:] != ".xml": continue if name == "entities.xml": r = read_entities(unicode(def_path, "utf-8") + name) else: r = read_def(unicode(def_path, "utf-8") + name) stream = StringIO()
if value is None: return '' return value else: if value is None: return '' return value def get_dict(element): rst = {} children = element.getchildren() for i in children: rst[i.tag] = i.text return rst if __name__ == "__main__": import time path = "E://ChineseData.xml" o = read_cfg(path) print o print len(o) stream = StringIO() h = Hmf() h.write_object(o, stream) stream.seek(0) fd = open("E://out.hmf", "wb") fd.write(stream.read()) fd.close()
v1 = kv[1] rv[k1] = v1 return rv elif subfix == "_s": if value is None: return '' return value else: if value is None: return '' return value if __name__ == "__main__": import sys, os, dircache from StringIO import StringIO base_path = '''E:/mogo/doc/product/配置表/xml文件最终版/''' out_path = '''E:/hmfoutput/''' files = dircache.listdir(unicode(base_path, "utf-8")) for name in files: if name == '.svn': continue print name r = read_cfg(unicode(base_path, "utf-8") + name) stream = StringIO() #print r h = Hmf() h.write_object(r, stream) stream.seek(0) fd = open(out_path + name[:-4] + '.bytes', "wb") fd.write(stream.read()) fd.close()