• Home
  • Raw
  • Download

Lines Matching +full:write +full:- +full:output

2 gensuitemodule - Generate an AE suite module from an aete/aeut resource
31 DEFAULT_STANDARD_PACKAGEFOLDER=os.path.join(_MAC_LIB_FOLDER, 'lib-scriptpackages')
35 sys.stderr.write("Usage: %s [opts] application-or-resource-file\n" % sys.argv[0])
36 sys.stderr.write("""Options:
37 --output pkgdir Pathname of the output package (short: -o)
38 --resource Parse resource file in stead of launching application (-r)
39 --base package Use another base package in stead of default StdSuites (-b)
40 --edit old=new Edit suite names, use empty new to skip a suite (-e)
41 --creator code Set creator code for package (-c)
42 --dump Dump aete resource to stdout in stead of creating module (-d)
43 --verbose Tell us what happens (-v)
50 LONGOPTS = ("resource", "base=", "output=", "edit=", "creator=", "dump", "verbose")
58 output = None
65 if o in ('-r', '--resource'):
67 if o in ('-b', '--base'):
69 if o in ('-o', '--output'):
70 output = a
71 if o in ('-e', '--edit'):
76 if o in ('-c', '--creator'):
78 sys.stderr.write("creator must be 4-char string\n")
81 if o in ('-d', '--dump'):
83 if o in ('-v', '--verbose'):
87 if output and len(args) > 1:
88 sys.stderr.write("%s: cannot specify --output with multiple inputs\n" % sys.argv[0])
92 process_func(filename, output=output, basepkgname=basepkgname,
100 # Ask for save-filename for each module
105 appsfolder = Carbon.Folder.FSFindFolder(-32765, 'apps', 0)
147 def processfile_fromresource(fullname, output=None, basepkgname=None, argument
182 compileaetelist(aetelist, fullname, output=output,
186 def processfile(fullname, output=None, basepkgname=None, argument
197 if arg[0] in (-1701, -192): # errAEDescNotFound, resNotFound
223 compileaete(aete, None, fullname, output=output, basepkgname=basepkgname,
256 return reply[1]['----'], cr
259 def compileaetelist(aetelist, fullname, output=None, basepkgname=None, argument
262 compileaete(aete, resinfo, fullname, output=output,
266 def dumpaetelist(aetelist, output): argument
268 pprint.pprint(aetelist, output)
279 verbose.write("%d processed + %d unprocessed = %d total\n" %
294 # It is presented bottom-up instead of top-down because there are direct
295 # references to the lower-level part-decoders from the high-level part-decoders.
352 print '->', repr(res)
433 def compileaete(aete, resinfo, fname, output=None, basepkgname=None, argument
447 if output:
448 # XXXX Put this in site-packages if it isn't a full pathname?
449 if not os.path.exists(output):
450 os.mkdir(output)
451 pathname = output
455 output = pathname
473 compiler = SuiteCompiler(suite, basepackage, output, edit_modnames, verbose)
483 initfilename = os.path.join(output, '__init__.py')
486 fp.write('"""\n')
487 fp.write("Package generated from %s\n"%ascii(fname))
489 fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2])))
490 fp.write('"""\n')
491 fp.write('import aetools\n')
492 fp.write('Error = aetools.Error\n')
495 fp.write("import %s\n" % modname)
496 fp.write("\n\n_code_to_module = {\n")
498 fp.write(" '%s' : %s,\n"%(ascii(code), modname))
499 fp.write("}\n\n")
500 fp.write("\n\n_code_to_fullname = {\n")
502 fp.write(" '%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname))
503 fp.write("}\n\n")
505 fp.write("from %s import *\n"%modname)
508 fp.write("\ndef getbaseclasses(v):\n")
509 fp.write(" if not getattr(v, '_propdict', None):\n")
510 fp.write(" v._propdict = {}\n")
511 fp.write(" v._elemdict = {}\n")
512 fp.write(" for superclassname in getattr(v, '_superclassnames', []):\n")
513 fp.write(" superclass = eval(superclassname)\n")
514 fp.write(" getbaseclasses(superclass)\n")
515 fp.write(" v._propdict.update(getattr(superclass, '_propdict', {}))\n")
516 fp.write(" v._elemdict.update(getattr(superclass, '_elemdict', {}))\n")
517 fp.write(" v._propdict.update(getattr(v, '_privpropdict', {}))\n")
518 fp.write(" v._elemdict.update(getattr(v, '_privelemdict', {}))\n")
519 fp.write("\n")
520 fp.write("import StdSuites\n")
523 …fp.write("\n#\n# Set property and element dictionaries now that all classes have been defined\n#\n…
526 fp.write("getbaseclasses(%s)\n" % v)
528 # Generate a code-to-name mapper for all of the types (classes) declared in this module
531 fp.write("\n#\n# Indices of types declared in this module\n#\n")
532 fp.write("_classdeclarations = {\n")
535 fp.write(" %r : %s,\n" % (k, v))
538 fp.write("}\n")
542 fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1]))
544 fp.write(",\n %s_Events"%modname)
545 fp.write(",\n aetools.TalkTo):\n")
546 fp.write(" _signature = %r\n\n"%(creatorsignature,))
547 fp.write(" _moduleName = '%s'\n\n"%packagename)
549 fp.write(" _elemdict = %s._elemdict\n" % application_class)
550 fp.write(" _propdict = %s._propdict\n" % application_class)
554 def __init__(self, suite, basepackage, output, edit_modnames, verbose): argument
558 self.output = output
571 """Parse a single suite without generating the output. This step is needed
580 self.pathname = EasyDialogs.AskFileForSave(message='Python output file',
587 self.pathname = os.path.join(self.output, modname + '.py')
630 # Sort various lists, so re-generated source is easier compared
634 if k1[1] < k2[1]: return -1
638 return -1
652 fp.write('"""Suite %s: %s\n' % (ascii(name), ascii(desc)))
653 fp.write("Level %d, version %d\n\n" % (level, version))
654 fp.write("Generated from %s\n"%ascii(fname))
655 fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \
657 fp.write('"""\n\n')
659 fp.write('import aetools\n')
660 fp.write('import MacOS\n\n')
661 fp.write("_code = %r\n\n"% (code,))
665 fp.write('from %s import *\n'%self.basepackage._code_to_fullname[code][0])
669 fp.write('from %s import *\n'%self.basepackage._code_to_fullname[code.lower()][0])
682 fp.write(" pass\n\n")
704 modshortname = string.split(self.basemodule.__name__, '.')[-1]
706 self.fp.write("class %s(%s):\n\n"%(classname, baseclassname))
708 self.fp.write("class %s:\n\n"%classname)
716 # generate name->keyword map
719 fp.write(" _argmap_%s = {\n"%funcname)
721 fp.write(" %r : %r,\n"%(identify(a[0]), a[1]))
722 fp.write(" }\n\n")
730 fp.write(" def %s(self, "%funcname)
733 fp.write("_object, ") # Include direct object, if it has one
735 fp.write("_object=None, ") # Also include if it is optional
737 fp.write("_no_object=None, ") # For argument checking
738 fp.write("_attributes={}, **_arguments):\n") # include attribute dict and args
741 # available documentation, due to our name-remaping)
743 fp.write(' """%s: %s\n'%(ascii(name), ascii(desc)))
745 fp.write(" Required argument: %s\n"%getdatadoc(accepts))
747 fp.write(" Optional argument: %s\n"%getdatadoc(accepts))
749 fp.write(" Keyword argument %s: %s\n"%(identify(arg[0]),
751 fp.write(" Keyword argument _attributes: AppleEvent attribute dictionary\n")
753 fp.write(" Returns: %s\n"%getdatadoc(returns))
754 fp.write(' """\n')
758 fp.write(" _code = %r\n"% (code,))
759 fp.write(" _subcode = %r\n\n"% (subcode,))
764 fp.write(" aetools.keysubst(_arguments, self._argmap_%s)\n"%funcname)
766 fp.write(" if _arguments: raise TypeError, 'No optional args expected'\n")
771 fp.write(" _arguments['----'] = _object\n")
773 fp.write(" if _object:\n")
774 fp.write(" _arguments['----'] = _object\n")
776 … fp.write(" if _no_object is not None: raise TypeError, 'No direct arg expected'\n")
777 fp.write("\n")
779 # Do enum-name substitution
786 fp.write(" aetools.enumsubst(_arguments, %r, _Enum_%s)\n" %
789 fp.write("\n")
793 fp.write(" _reply, _arguments, _attributes = self.send(_code, _subcode,\n")
794 fp.write(" _arguments, _attributes)\n")
798 fp.write(" if _arguments.get('errn', 0):\n")
799 fp.write(" raise aetools.Error, aetools.decodeerror(_arguments)\n")
800 fp.write(" # XXXX Optionally decode result\n")
804 fp.write(" if '----' in _arguments:\n")
806 fp.write(" # XXXX Should do enum remapping here...\n")
807 fp.write(" return _arguments['----']\n")
808 fp.write("\n")
820 # This class stores the code<->name translations for a single module. It is used
928 self.fp.write("import %s\n"%mapper.modulename)
962 self.fp.write("import %s\n"%modname)
972 self.fp.write("\n%s = %s\n"%(pname, othername))
975 self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname)
976 self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(desc)))
977 self.fp.write(' want = %r\n' % (code,))
999 self.fp.write("\n_Prop_%s = _Prop_%s\n"%(pname, othername))
1002 self.fp.write("class _Prop_%s(aetools.NProperty):\n" % pname)
1003 self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(what[1])))
1004 self.fp.write(" which = %r\n" % (code,))
1005 self.fp.write(" want = %r\n" % (what[0],))
1008 self.fp.write("%s = _Prop_%s()\n" % (pname, pname))
1013 self.fp.write("# element %r as %s\n" % (code, keyform))
1025 raise RuntimeError, "About to skip non-empty class"
1050 self.fp.write("%s._superclassnames = %r\n"%(cname, superclassnames))
1059 self.fp.write("# XXXX %s element %r not found!!\n"%(cname, ecode))
1067 self.fp.write("%s._privpropdict = {\n"%cname)
1069 self.fp.write(" '%s' : _Prop_%s,\n"%(n, n))
1070 self.fp.write("}\n")
1071 self.fp.write("%s._privelemdict = {\n"%cname)
1073 self.fp.write(" '%s' : %s,\n"%(n, fulln))
1074 self.fp.write("}\n")
1081 self.fp.write("class %s(aetools.NComparison):\n" % iname)
1082 self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(comment)))
1088 self.fp.write("%s = {\n" % name)
1091 self.fp.write("}\n\n")
1097 self.fp.write(" %r : %r,\t# %s\n" % (identify(name), code, ascii(desc)))
1104 … self.fp.write("_Enum_%s = None # XXXX enum %s not found!!\n"%(identify(enum), ascii(enum)))
1108 self.fp.write("from %s import %s\n"%(module, name))
1113 self.fp.write("\n#\n# Indices of types declared in this module\n#\n")
1115 self.fp.write("_classdeclarations = {\n")
1119 self.fp.write(" %r : %s,\n" % (k, v))
1120 self.fp.write("}\n")
1122 self.fp.write("\n_propdeclarations = {\n")
1126 self.fp.write(" %r : _Prop_%s,\n" % (k, v))
1127 self.fp.write("}\n")
1129 self.fp.write("\n_compdeclarations = {\n")
1133 self.fp.write(" %r : %s,\n" % (k, v))
1134 self.fp.write("}\n")
1136 self.fp.write("\n_enumdeclarations = {\n")
1140 self.fp.write(" %r : %s,\n" % (k, v))
1141 self.fp.write("}\n")
1145 return "%r -- %r %s" % (type, description, compiledataflags(flags))
1178 """Return a string with all non-ascii characters hex-encoded"""
1191 - replace space by _
1192 - replace other illegal chars by _xx_ (hex code)
1193 - append _ if the result is a python keyword