def writefile(f, defs): f.write("entitydefs = {\n") items = sorted(defs.items()) for name, (charcode, comment) in items: if charcode[:2] == '&#': code = int(charcode[2:-1]) if code < 256: charcode = "'\%o'" % code else: charcode = repr(charcode) else: charcode = repr(charcode) comment = TextTools.collapse(comment) f.write(" '%s':\t%s, \t# %s\n" % (name, charcode, comment)) f.write('\n}\n')
def writefile(f,defs): f.write("entitydefs = {\n") items = sorted(defs.items()) for name, (charcode,comment) in items: if charcode[:2] == '&#': code = int(charcode[2:-1]) if code < 256: charcode = "'\%o'" % code else: charcode = repr(charcode) else: charcode = repr(charcode) comment = TextTools.collapse(comment) f.write(" '%s':\t%s, \t# %s\n" % (name,charcode,comment)) f.write('\n}\n')
#!/usr/local/bin/python