parameters: (aete, resinfo, fname, output=None, basepkgname=None,
          edit_modnames=None, creatorsignature=None, verbose=None)
docstring: Generate code for a full aete resource. fname passed for doc purposes
docstring_summary: Generate code for a full aete resource. fname passed for doc purposes
docstring_tokens: Generate code for a full aete resource . fname passed for doc purposes
function: def compileaete(aete, resinfo, fname, output=None, basepkgname=None,
          edit_modnames=None, creatorsignature=None, verbose=None):
      """Generate code for a full aete resource. fname passed for doc purposes"""
      [version, language, script, suites] = aete
      major, minor = divmod(version, 256)
      if not creatorsignature:
          creatorsignature, dummy = MacOS.GetCreatorAndType(fname)
      packagename = identify(os.path.splitext(os.path.basename(fname))[0])
      if language:
          packagename = packagename+'_lang%d'%language
      if script:
          packagename = packagename+'_script%d'%script
      if len(packagename) > 27:
          packagename = packagename[:27]
      if output:
          # XXXX Put this in site-packages if it isn't a full pathname?
          if not os.path.exists(output):
              os.mkdir(output)
          pathname = output
      else:
          pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename,
              defaultLocation=DEFAULT_USER_PACKAGEFOLDER)
          output = pathname
      if not pathname:
          return
      packagename = os.path.split(os.path.normpath(pathname))[1]
      if not basepkgname:
          basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)',
              defaultLocation=DEFAULT_STANDARD_PACKAGEFOLDER)
      if basepkgname:
          dirname, basepkgname = os.path.split(os.path.normpath(basepkgname))
          if dirname and not dirname in sys.path:
              sys.path.insert(0, dirname)
          basepackage = __import__(basepkgname)
      else:
          basepackage = None
      suitelist = []
      allprecompinfo = []
      allsuites = []
      for suite in suites:
          compiler = SuiteCompiler(suite, basepackage, output, edit_modnames, verbose)
          code, modname, precompinfo = compiler.precompilesuite()
          if not code:
              continue
          allprecompinfo = allprecompinfo + precompinfo
          suiteinfo = suite, pathname, modname
          suitelist.append((code, modname))
          allsuites.append(compiler)
      for compiler in allsuites:
          compiler.compilesuite(major, minor, language, script, fname, allprecompinfo)
      initfilename = os.path.join(output, '__init__.py')
      fp = open(initfilename, 'w')
      MacOS.SetCreatorAndType(initfilename, 'Pyth', 'TEXT')
      fp.write('"""\n')
      fp.write("Package generated from %s\n"%ascii(fname))
      if resinfo:
          fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2])))
      fp.write('"""\n')
      fp.write('import aetools\n')
      fp.write('Error = aetools.Error\n')
      suitelist.sort()
      for code, modname in suitelist:
          fp.write("import %s\n" % modname)
      fp.write("\n\n_code_to_module = {\n")
      for code, modname in suitelist:
          fp.write("    '%s' : %s,\n"%(ascii(code), modname))
      fp.write("}\n\n")
      fp.write("\n\n_code_to_fullname = {\n")
      for code, modname in suitelist:
          fp.write("    '%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname))
      fp.write("}\n\n")
      for code, modname in suitelist:
          fp.write("from %s import *\n"%modname)
  
      # Generate property dicts and element dicts for all types declared in this module
      fp.write("\ndef getbaseclasses(v):\n")
      fp.write("    if not getattr(v, '_propdict', None):\n")
      fp.write("        v._propdict = {}\n")
      fp.write("        v._elemdict = {}\n")
      fp.write("        for superclassname in getattr(v, '_superclassnames', []):\n")
      fp.write("            superclass = eval(superclassname)\n")
      fp.write("            getbaseclasses(superclass)\n")
      fp.write("            v._propdict.update(getattr(superclass, '_propdict', {}))\n")
      fp.write("            v._elemdict.update(getattr(superclass, '_elemdict', {}))\n")
      fp.write("        v._propdict.update(getattr(v, '_privpropdict', {}))\n")
      fp.write("        v._elemdict.update(getattr(v, '_privelemdict', {}))\n")
      fp.write("\n")
      fp.write("import StdSuites\n")
      allprecompinfo.sort()
      if allprecompinfo:
          fp.write("\n#\n# Set property and element dictionaries now that all classes have been defined\n#\n")
          for codenamemapper in allprecompinfo:
              for k, v in codenamemapper.getall('class'):
                  fp.write("getbaseclasses(%s)\n" % v)
  
      # Generate a code-to-name mapper for all of the types (classes) declared in this module
      application_class = None
      if allprecompinfo:
          fp.write("\n#\n# Indices of types declared in this module\n#\n")
          fp.write("_classdeclarations = {\n")
          for codenamemapper in allprecompinfo:
              for k, v in codenamemapper.getall('class'):
                  fp.write("    %r : %s,\n" % (k, v))
                  if k == 'capp':
                      application_class = v
          fp.write("}\n")
  
  
      if suitelist:
          fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1]))
          for code, modname in suitelist[1:]:
              fp.write(",\n        %s_Events"%modname)
          fp.write(",\n        aetools.TalkTo):\n")
          fp.write("    _signature = %r\n\n"%(creatorsignature,))
          fp.write("    _moduleName = '%s'\n\n"%packagename)
          if application_class:
              fp.write("    _elemdict = %s._elemdict\n" % application_class)
              fp.write("    _propdict = %s._propdict\n" % application_class)
      fp.close()
function_tokens: def compileaete ( aete , resinfo , fname , output = None , basepkgname = None , edit_modnames = None , creatorsignature = None , verbose = None ) : [ version , language , script , suites ] = aete major , minor = divmod ( version , 256 ) if not creatorsignature : creatorsignature , dummy = MacOS . GetCreatorAndType ( fname ) packagename = identify ( os . path . splitext ( os . path . basename ( fname ) ) [ 0 ] ) if language : packagename = packagename + '_lang%d' % language if script : packagename = packagename + '_script%d' % script if len ( packagename ) > 27 : packagename = packagename [ : 27 ] if output : # XXXX Put this in site-packages if it isn't a full pathname? if not os . path . exists ( output ) : os . mkdir ( output ) pathname = output else : pathname = EasyDialogs . AskFolder ( message = 'Create and select package folder for %s' % packagename , defaultLocation = DEFAULT_USER_PACKAGEFOLDER ) output = pathname if not pathname : return packagename = os . path . split ( os . path . normpath ( pathname ) ) [ 1 ] if not basepkgname : basepkgname = EasyDialogs . AskFolder ( message = 'Package folder for base suite (usually StdSuites)' , defaultLocation = DEFAULT_STANDARD_PACKAGEFOLDER ) if basepkgname : dirname , basepkgname = os . path . split ( os . path . normpath ( basepkgname ) ) if dirname and not dirname in sys . path : sys . path . insert ( 0 , dirname ) basepackage = __import__ ( basepkgname ) else : basepackage = None suitelist = [ ] allprecompinfo = [ ] allsuites = [ ] for suite in suites : compiler = SuiteCompiler ( suite , basepackage , output , edit_modnames , verbose ) code , modname , precompinfo = compiler . precompilesuite ( ) if not code : continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite , pathname , modname suitelist . append ( ( code , modname ) ) allsuites . append ( compiler ) for compiler in allsuites : compiler . compilesuite ( major , minor , language , script , fname , allprecompinfo ) initfilename = os . path . join ( output , '__init__.py' ) fp = open ( initfilename , 'w' ) MacOS . SetCreatorAndType ( initfilename , 'Pyth' , 'TEXT' ) fp . write ( '"""\n' ) fp . write ( "Package generated from %s\n" % ascii ( fname ) ) if resinfo : fp . write ( "Resource %s resid %d %s\n" % ( ascii ( resinfo [ 1 ] ) , resinfo [ 0 ] , ascii ( resinfo [ 2 ] ) ) ) fp . write ( '"""\n' ) fp . write ( 'import aetools\n' ) fp . write ( 'Error = aetools.Error\n' ) suitelist . sort ( ) for code , modname in suitelist : fp . write ( "import %s\n" % modname ) fp . write ( "\n\n_code_to_module = {\n" ) for code , modname in suitelist : fp . write ( "    '%s' : %s,\n" % ( ascii ( code ) , modname ) ) fp . write ( "}\n\n" ) fp . write ( "\n\n_code_to_fullname = {\n" ) for code , modname in suitelist : fp . write ( "    '%s' : ('%s.%s', '%s'),\n" % ( ascii ( code ) , packagename , modname , modname ) ) fp . write ( "}\n\n" ) for code , modname in suitelist : fp . write ( "from %s import *\n" % modname ) # Generate property dicts and element dicts for all types declared in this module fp . write ( "\ndef getbaseclasses(v):\n" ) fp . write ( "    if not getattr(v, '_propdict', None):\n" ) fp . write ( "        v._propdict = {}\n" ) fp . write ( "        v._elemdict = {}\n" ) fp . write ( "        for superclassname in getattr(v, '_superclassnames', []):\n" ) fp . write ( "            superclass = eval(superclassname)\n" ) fp . write ( "            getbaseclasses(superclass)\n" ) fp . write ( "            v._propdict.update(getattr(superclass, '_propdict', {}))\n" ) fp . write ( "            v._elemdict.update(getattr(superclass, '_elemdict', {}))\n" ) fp . write ( "        v._propdict.update(getattr(v, '_privpropdict', {}))\n" ) fp . write ( "        v._elemdict.update(getattr(v, '_privelemdict', {}))\n" ) fp . write ( "\n" ) fp . write ( "import StdSuites\n" ) allprecompinfo . sort ( ) if allprecompinfo : fp . write ( "\n#\n# Set property and element dictionaries now that all classes have been defined\n#\n" ) for codenamemapper in allprecompinfo : for k , v in codenamemapper . getall ( 'class' ) : fp . write ( "getbaseclasses(%s)\n" % v ) # Generate a code-to-name mapper for all of the types (classes) declared in this module application_class = None if allprecompinfo : fp . write ( "\n#\n# Indices of types declared in this module\n#\n" ) fp . write ( "_classdeclarations = {\n" ) for codenamemapper in allprecompinfo : for k , v in codenamemapper . getall ( 'class' ) : fp . write ( "    %r : %s,\n" % ( k , v ) ) if k == 'capp' : application_class = v fp . write ( "}\n" ) if suitelist : fp . write ( "\n\nclass %s(%s_Events" % ( packagename , suitelist [ 0 ] [ 1 ] ) ) for code , modname in suitelist [ 1 : ] : fp . write ( ",\n        %s_Events" % modname ) fp . write ( ",\n        aetools.TalkTo):\n" ) fp . write ( "    _signature = %r\n\n" % ( creatorsignature , ) ) fp . write ( "    _moduleName = '%s'\n\n" % packagename ) if application_class : fp . write ( "    _elemdict = %s._elemdict\n" % application_class ) fp . write ( "    _propdict = %s._propdict\n" % application_class ) fp . close ( )