Look what happened to my beautiful code :(
'''A script for seemlesly copying the data from the stix-tbl.ascii*
file to a set
of python dicts. Dicts are then saved to .py coresponding files, for
later retrieval.
Currently used table file:
http://www.ams.org/STIX/bnb/stix-tbl.ascii-2005-09-24
'''
tablefilename = 'stix-tbl.ascii-2005-09-24'
dictnames = ['uni2type1', 'type12uni', 'uni2tex', 'tex2uni']
dicts = {}
# initialize the dicts
for name in dictnames:
dicts[name] = {}
for line in file(tablefilename):
if line[:2]!=' 0': continue
uninum = int(line[2:6].strip().lower(), 16)
type1name = line[12:37].strip()
texname = line[83:110].strip()
if type1name:
dicts['uni2type1'][uninum] = type1name
dicts['type12uni'][type1name] = uninum
if texname:
dicts['uni2tex'][uninum] = texname
dicts['tex2uni'][texname] = uninum
template = '''# Automatically generated file.
# Don't edit this file. Edit _mathtext_manual_data.py instead
%(name)s = {%(pairs)s
}
try:
from _mathtext_manual_data import _%(name)s
%(name)s.update(_%(name)s)
except (TypeError, SyntaxError): # Just these exceptions should be raised
raise
except: # All other exceptions should be silent. Even ImportError
pass
'''
# automatically generating .py module files, used by importers
for name in ('uni2type1', 'uni2tex'):
pairs = ''
for key, value in dicts[name].items():
value = value.replace("'","\\'")
value = value.replace('"','\\"')
pair = "%(key)i : r'%(value)s',\n"%(locals())
pairs += pair
file(name + '.py','w').write(template%{'name':name, 'pairs':pairs})
for name in ('type12uni', 'tex2uni'):
pairs = ''
for key, value in dicts[name].items():
key = key.replace("'","\\'")
key = key.replace('"','\\"')
pair = "r'%(key)s' : %(value)i,\n"%(locals())
pairs += pair
file(name + '.py','w').write(template%{'name':name, 'pairs':pairs})
# An example
from uni2tex import uni2tex
from uni2type1 import uni2type1
unichar = u'\u00d7'
uninum = ord(unichar)
print uni2tex[uninum]
print uni2type1[uninum]
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel