mirror of
https://github.com/python/cpython.git
synced 2025-08-25 03:04:55 +00:00
satisfy the tabnanny
This commit is contained in:
parent
9082cdd009
commit
0b7b4b8a22
3 changed files with 333 additions and 333 deletions
|
@ -21,15 +21,15 @@ def parse(text,pos=0,endpos=None):
|
|||
|
||||
pos = 0
|
||||
if endpos is None:
|
||||
endpos = len(text)
|
||||
endpos = len(text)
|
||||
d = {}
|
||||
while 1:
|
||||
m = entityRE.search(text,pos,endpos)
|
||||
if not m:
|
||||
break
|
||||
name,charcode,comment = m.groups()
|
||||
d[name] = charcode,comment
|
||||
pos = m.end()
|
||||
m = entityRE.search(text,pos,endpos)
|
||||
if not m:
|
||||
break
|
||||
name,charcode,comment = m.groups()
|
||||
d[name] = charcode,comment
|
||||
pos = m.end()
|
||||
return d
|
||||
|
||||
def writefile(f,defs):
|
||||
|
@ -38,27 +38,27 @@ def writefile(f,defs):
|
|||
items = defs.items()
|
||||
items.sort()
|
||||
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))
|
||||
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')
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 1:
|
||||
infile = open(sys.argv[1])
|
||||
infile = open(sys.argv[1])
|
||||
else:
|
||||
infile = sys.stdin
|
||||
infile = sys.stdin
|
||||
if len(sys.argv) > 2:
|
||||
outfile = open(sys.argv[2],'w')
|
||||
outfile = open(sys.argv[2],'w')
|
||||
else:
|
||||
outfile = sys.stdout
|
||||
outfile = sys.stdout
|
||||
text = infile.read()
|
||||
defs = parse(text)
|
||||
writefile(outfile,defs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue