Lines Matching refs:fp
484 fp = open(initfilename, 'w')
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)
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)
551 fp.close()
566 self.fp = None
649 self.fp = fp = open(self.pathname, 'w')
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")
684 …objc = ObjectCompiler(fp, self.modname, basemodule, precompinfo, interact=(self.edit_modnames is N…
706 self.fp.write("class %s(%s):\n\n"%(classname, baseclassname))
708 self.fp.write("class %s:\n\n"%classname)
713 fp = self.fp
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
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")
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")
891 def __init__(self, fp, modname, basesuite, othernamemappers=None, interact=1, argument
893 self.fp = fp
927 if self.fp:
928 self.fp.write("import %s\n"%mapper.modulename)
933 if self.fp:
962 self.fp.write("import %s\n"%modname)
971 if self.fp:
972 self.fp.write("\n%s = %s\n"%(pname, othername))
974 if self.fp:
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,))
998 if self.fp:
999 self.fp.write("\n_Prop_%s = _Prop_%s\n"%(pname, othername))
1001 if self.fp:
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],))
1007 if is_application_class and self.fp:
1008 self.fp.write("%s = _Prop_%s()\n" % (pname, pname))
1012 if self.fp:
1013 self.fp.write("# element %r as %s\n" % (code, keyform))
1021 if self.fp and (elements or len(properties) > 1 or (len(properties) == 1 and
1049 if self.fp:
1050 self.fp.write("%s._superclassnames = %r\n"%(cname, superclassnames))
1058 if self.fp:
1059 self.fp.write("# XXXX %s element %r not found!!\n"%(cname, ecode))
1066 if self.fp:
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")
1080 if self.fp:
1081 self.fp.write("class %s(aetools.NComparison):\n" % iname)
1082 self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(comment)))
1087 if self.fp:
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)))
1103 if self.fp:
1104 … self.fp.write("_Enum_%s = None # XXXX enum %s not found!!\n"%(identify(enum), ascii(enum)))
1107 if self.fp:
1108 self.fp.write("from %s import %s\n"%(module, name))
1111 if not self.fp:
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")