Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21f6758

Browse files
committed
- If an OSA identifier is a Python reserved word we now append an _
in stead of prepending it, which messes up "import * from". - A few ascii()s added again. - Changed the getbaseclasses a little, but it still isn't perfect.
1 parent 442c7c7 commit 21f6758

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

Mac/scripts/gensuitemodule.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,17 @@ def compileaete(aete, resinfo, fname):
295295

296296
# Generate property dicts and element dicts for all types declared in this module
297297
fp.write("def getbaseclasses(v):\n")
298-
fp.write("\tif hasattr(v, '_superclassnames'):\n")
298+
fp.write("\tif hasattr(v, '_superclassnames') and v._superclassnames:\n")
299299
fp.write("\t\tv._propdict = {}\n")
300300
fp.write("\t\tv._elemdict = {}\n")
301301
fp.write("\t\tfor superclass in v._superclassnames:\n")
302-
fp.write("\t\t\tgetbaseclasses(superclass)\n")
303-
fp.write("\t\t\tv._propdict.update(getattr(eval(superclass), '_privpropdict'))\n")
304-
fp.write("\t\t\tv._elemdict.update(getattr(eval(superclass), '_privelemdict'))\n")
302+
## fp.write("\t\t\tgetbaseclasses(superclass)\n")
303+
fp.write("\t\t\tv._propdict.update(getattr(eval(superclass), '_privpropdict', {}))\n")
304+
fp.write("\t\t\tv._elemdict.update(getattr(eval(superclass), '_privelemdict', {}))\n")
305305
fp.write("\t\tv._propdict.update(v._privpropdict)\n")
306306
fp.write("\t\tv._elemdict.update(v._privelemdict)\n")
307+
fp.write("\t\tv._superclassnames = None\n")
308+
fp.write("\n")
307309
fp.write("import StdSuites\n")
308310
if allprecompinfo:
309311
fp.write("\n#\n# Set property and element dictionaries now that all classes have been defined\n#\n")
@@ -474,7 +476,7 @@ def compileevent(fp, event, enumsneeded):
474476
# Generate doc string (important, since it may be the only
475477
# available documentation, due to our name-remaping)
476478
#
477-
fp.write('\t\t"""%s: %s\n'%(name, desc))
479+
fp.write('\t\t"""%s: %s\n'%(ascii(name), ascii(desc)))
478480
if has_arg:
479481
fp.write("\t\tRequired argument: %s\n"%getdatadoc(accepts))
480482
elif opt_arg:
@@ -800,7 +802,7 @@ def compileenumeration(self, enum):
800802

801803
def compileenumerator(self, item):
802804
[name, code, desc] = item
803-
self.fp.write("\t%s : %s,\t# %s\n" % (`identify(name)`, `code`, desc))
805+
self.fp.write("\t%s : %s,\t# %s\n" % (`identify(name)`, `code`, ascii(desc)))
804806

805807
def checkforenum(self, enum):
806808
"""This enum code is used by an event. Make sure it's available"""
@@ -887,7 +889,7 @@ def identify(str):
887889
- prepend _ if the result is a python keyword
888890
"""
889891
if not str:
890-
return "_empty_ae_name"
892+
return "empty_ae_name_"
891893
rv = ''
892894
ok = string.ascii_letters + '_'
893895
ok2 = ok + string.digits
@@ -900,7 +902,7 @@ def identify(str):
900902
rv = rv + '_%02.2x_'%ord(c)
901903
ok = ok2
902904
if keyword.iskeyword(rv):
903-
rv = '_' + rv
905+
rv = rv + '_'
904906
return rv
905907

906908
# Call the main program

0 commit comments

Comments
 (0)