<s> """<STR_LIT>""" <EOL> from warnings import warnpy3k <EOL> warnpy3k ( "<STR_LIT>" , stacklevel = <NUM_LIT:2> ) <EOL> from Carbon . AppleEvents import * <EOL> import struct <EOL> from types import * <EOL> import string <EOL> def pack ( * args , ** kwargs ) : <EOL> from aepack import pack <EOL> return pack ( * args , ** kwargs ) <EOL> def nice ( s ) : <EOL> """<STR_LIT>""" <EOL> if type ( s ) is StringType : return repr ( s ) <EOL> else : return str ( s ) <EOL> class Unknown : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type , data ) : <EOL> self . type = type <EOL> self . data = data <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . type , self . data ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( self . data , self . type ) <EOL> class Enum : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , enum ) : <EOL> self . enum = "<STR_LIT>" % str ( enum ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . enum , ) <EOL> def __str__ ( self ) : <EOL> return string . strip ( self . enum ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( self . enum , typeEnumeration ) <EOL> def IsEnum ( x ) : <EOL> return isinstance ( x , Enum ) <EOL> def mkenum ( enum ) : <EOL> if IsEnum ( enum ) : return enum <EOL> return Enum ( enum ) <EOL> class InsertionLoc : <EOL> def __init__ ( self , of , pos ) : <EOL> self . of = of <EOL> self . pos = pos <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . of , self . pos ) <EOL> def __aepack__ ( self ) : <EOL> rec = { '<STR_LIT>' : self . of , '<STR_LIT>' : self . pos } <EOL> return pack ( rec , forcetype = '<STR_LIT>' ) <EOL> def beginning ( of ) : <EOL> return InsertionLoc ( of , Enum ( '<STR_LIT>' ) ) <EOL> def end ( of ) : <EOL> return InsertionLoc ( of , Enum ( '<STR_LIT>' ) ) <EOL> class Boolean : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , bool ) : <EOL> self . bool = ( not not bool ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . bool , ) <EOL> def __str__ ( self ) : <EOL> if self . bool : <EOL> return "<STR_LIT:True>" <EOL> else : <EOL> return "<STR_LIT:False>" <EOL> def __aepack__ ( self ) : <EOL> return pack ( struct . pack ( '<STR_LIT:b>' , self . bool ) , '<STR_LIT:bool>' ) <EOL> def IsBoolean ( x ) : <EOL> return isinstance ( x , Boolean ) <EOL> def mkboolean ( bool ) : <EOL> if IsBoolean ( bool ) : return bool <EOL> return Boolean ( bool ) <EOL> class Type : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type ) : <EOL> self . type = "<STR_LIT>" % str ( type ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . type , ) <EOL> def __str__ ( self ) : <EOL> return string . strip ( self . type ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( self . type , typeType ) <EOL> def IsType ( x ) : <EOL> return isinstance ( x , Type ) <EOL> def mktype ( type ) : <EOL> if IsType ( type ) : return type <EOL> return Type ( type ) <EOL> class Keyword : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , keyword ) : <EOL> self . keyword = "<STR_LIT>" % str ( keyword ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % repr ( self . keyword ) <EOL> def __str__ ( self ) : <EOL> return string . strip ( self . keyword ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( self . keyword , typeKeyword ) <EOL> def IsKeyword ( x ) : <EOL> return isinstance ( x , Keyword ) <EOL> class Range : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , start , stop ) : <EOL> self . start = start <EOL> self . stop = stop <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . start , self . stop ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( nice ( self . start ) , nice ( self . stop ) ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( { '<STR_LIT>' : self . start , '<STR_LIT>' : self . stop } , '<STR_LIT>' ) <EOL> def IsRange ( x ) : <EOL> return isinstance ( x , Range ) <EOL> class Comparison : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , obj1 , relo , obj2 ) : <EOL> self . obj1 = obj1 <EOL> self . relo = "<STR_LIT>" % str ( relo ) <EOL> self . obj2 = obj2 <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . obj1 , self . relo , self . obj2 ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( nice ( self . obj1 ) , string . strip ( self . relo ) , nice ( self . obj2 ) ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( { '<STR_LIT>' : self . obj1 , <EOL> '<STR_LIT>' : mkenum ( self . relo ) , <EOL> '<STR_LIT>' : self . obj2 } , <EOL> '<STR_LIT>' ) <EOL> def IsComparison ( x ) : <EOL> return isinstance ( x , Comparison ) <EOL> class NComparison ( Comparison ) : <EOL> def __init__ ( self , obj1 , obj2 ) : <EOL> Comparison . __init__ ( obj1 , self . relo , obj2 ) <EOL> class Ordinal : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , abso ) : <EOL> self . abso = "<STR_LIT>" % str ( abso ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . abso , ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:%s>" % ( string . strip ( self . abso ) ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( self . abso , '<STR_LIT>' ) <EOL> def IsOrdinal ( x ) : <EOL> return isinstance ( x , Ordinal ) <EOL> class NOrdinal ( Ordinal ) : <EOL> def __init__ ( self ) : <EOL> Ordinal . __init__ ( self , self . abso ) <EOL> class Logical : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , logc , term ) : <EOL> self . logc = "<STR_LIT>" % str ( logc ) <EOL> self . term = term <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . logc , self . term ) <EOL> def __str__ ( self ) : <EOL> if type ( self . term ) == ListType and len ( self . term ) == <NUM_LIT:2> : <EOL> return "<STR_LIT>" % ( nice ( self . term [ <NUM_LIT:0> ] ) , <EOL> string . strip ( self . logc ) , <EOL> nice ( self . term [ <NUM_LIT:1> ] ) ) <EOL> else : <EOL> return "<STR_LIT>" % ( string . strip ( self . logc ) , nice ( self . term ) ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( { '<STR_LIT>' : mkenum ( self . logc ) , '<STR_LIT>' : self . term } , '<STR_LIT>' ) <EOL> def IsLogical ( x ) : <EOL> return isinstance ( x , Logical ) <EOL> class StyledText : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , style , text ) : <EOL> self . style = style <EOL> self . text = text <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . style , self . text ) <EOL> def __str__ ( self ) : <EOL> return self . text <EOL> def __aepack__ ( self ) : <EOL> return pack ( { '<STR_LIT>' : self . style , '<STR_LIT>' : self . text } , '<STR_LIT>' ) <EOL> def IsStyledText ( x ) : <EOL> return isinstance ( x , StyledText ) <EOL> class AEText : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , script , style , text ) : <EOL> self . script = script <EOL> self . style = style <EOL> self . text = text <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . script , self . style , self . text ) <EOL> def __str__ ( self ) : <EOL> return self . text <EOL> def __aepack__ ( self ) : <EOL> return pack ( { keyAEScriptTag : self . script , keyAEStyles : self . style , <EOL> keyAEText : self . text } , typeAEText ) <EOL> def IsAEText ( x ) : <EOL> return isinstance ( x , AEText ) <EOL> class IntlText : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , script , language , text ) : <EOL> self . script = script <EOL> self . language = language <EOL> self . text = text <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . script , self . language , self . text ) <EOL> def __str__ ( self ) : <EOL> return self . text <EOL> def __aepack__ ( self ) : <EOL> return pack ( struct . pack ( '<STR_LIT>' , self . script , self . language ) + self . text , <EOL> typeIntlText ) <EOL> def IsIntlText ( x ) : <EOL> return isinstance ( x , IntlText ) <EOL> class IntlWritingCode : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , script , language ) : <EOL> self . script = script <EOL> self . language = language <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . script , self . language ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . script , self . language ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( struct . pack ( '<STR_LIT>' , self . script , self . language ) , <EOL> typeIntlWritingCode ) <EOL> def IsIntlWritingCode ( x ) : <EOL> return isinstance ( x , IntlWritingCode ) <EOL> class QDPoint : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , v , h ) : <EOL> self . v = v <EOL> self . h = h <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . v , self . h ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . v , self . h ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( struct . pack ( '<STR_LIT>' , self . v , self . h ) , <EOL> typeQDPoint ) <EOL> def IsQDPoint ( x ) : <EOL> return isinstance ( x , QDPoint ) <EOL> class QDRectangle : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , v0 , h0 , v1 , h1 ) : <EOL> self . v0 = v0 <EOL> self . h0 = h0 <EOL> self . v1 = v1 <EOL> self . h1 = h1 <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . v0 , self . h0 , self . v1 , self . h1 ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . v0 , self . h0 , self . v1 , self . h1 ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( struct . pack ( '<STR_LIT>' , self . v0 , self . h0 , self . v1 , self . h1 ) , <EOL> typeQDRectangle ) <EOL> def IsQDRectangle ( x ) : <EOL> return isinstance ( x , QDRectangle ) <EOL> class RGBColor : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , r , g , b ) : <EOL> self . r = r <EOL> self . g = g <EOL> self . b = b <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . r , self . g , self . b ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . r , self . g , self . b ) <EOL> def __aepack__ ( self ) : <EOL> return pack ( struct . pack ( '<STR_LIT>' , self . r , self . g , self . b ) , <EOL> typeRGBColor ) <EOL> def IsRGBColor ( x ) : <EOL> return isinstance ( x , RGBColor ) <EOL> class ObjectSpecifier : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , want , form , seld , fr = None ) : <EOL> self . want = want <EOL> self . form = form <EOL> self . seld = seld <EOL> self . fr = fr <EOL> def __repr__ ( self ) : <EOL> s = "<STR_LIT>" % ( self . want , self . form , self . seld ) <EOL> if self . fr : <EOL> s = s + "<STR_LIT>" % ( self . fr , ) <EOL> else : <EOL> s = s + "<STR_LIT:)>" <EOL> return s <EOL> def __aepack__ ( self ) : <EOL> return pack ( { '<STR_LIT>' : mktype ( self . want ) , <EOL> '<STR_LIT>' : mkenum ( self . form ) , <EOL> '<STR_LIT>' : self . seld , <EOL> '<STR_LIT>' : self . fr } , <EOL> '<STR_LIT>' ) <EOL> def IsObjectSpecifier ( x ) : <EOL> return isinstance ( x , ObjectSpecifier ) <EOL> class Property ( ObjectSpecifier ) : <EOL> def __init__ ( self , which , fr = None , want = '<STR_LIT>' ) : <EOL> ObjectSpecifier . __init__ ( self , want , '<STR_LIT>' , mktype ( which ) , fr ) <EOL> def __repr__ ( self ) : <EOL> if self . fr : <EOL> return "<STR_LIT>" % ( self . seld . type , self . fr ) <EOL> else : <EOL> return "<STR_LIT>" % ( self . seld . type , ) <EOL> def __str__ ( self ) : <EOL> if self . fr : <EOL> return "<STR_LIT>" % ( str ( self . seld ) , str ( self . fr ) ) <EOL> else : <EOL> return "<STR_LIT>" % str ( self . seld ) <EOL> class NProperty ( ObjectSpecifier ) : <EOL> def __init__ ( self , fr = None ) : <EOL> self . want = '<STR_LIT>' <EOL> ObjectSpecifier . __init__ ( self , self . want , '<STR_LIT>' , <EOL> mktype ( self . which ) , fr ) <EOL> def __repr__ ( self ) : <EOL> rv = "<STR_LIT>" % ( self . seld . type , ) <EOL> if self . fr : <EOL> rv = rv + "<STR_LIT>" % ( self . fr , ) <EOL> if self . want != '<STR_LIT>' : <EOL> rv = rv + "<STR_LIT>" % ( self . want , ) <EOL> return rv + "<STR_LIT:)>" <EOL> def __str__ ( self ) : <EOL> if self . fr : <EOL> return "<STR_LIT>" % ( str ( self . seld ) , str ( self . fr ) ) <EOL> else : <EOL> return "<STR_LIT>" % str ( self . seld ) <EOL> class SelectableItem ( ObjectSpecifier ) : <EOL> def __init__ ( self , want , seld , fr = None ) : <EOL> t = type ( seld ) <EOL> if t == StringType : <EOL> form = '<STR_LIT:name>' <EOL> elif IsRange ( seld ) : <EOL> form = '<STR_LIT>' <EOL> elif IsComparison ( seld ) or IsLogical ( seld ) : <EOL> form = '<STR_LIT:test>' <EOL> elif t == TupleType : <EOL> form , seld = seld <EOL> else : <EOL> form = '<STR_LIT>' <EOL> ObjectSpecifier . __init__ ( self , want , form , seld , fr ) <EOL> class ComponentItem ( SelectableItem ) : <EOL> _propdict = { } <EOL> _elemdict = { } <EOL> def __init__ ( self , which , fr = None ) : <EOL> SelectableItem . __init__ ( self , self . want , which , fr ) <EOL> def __repr__ ( self ) : <EOL> if not self . fr : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self . seld ) <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self . seld , self . fr ) <EOL> def __str__ ( self ) : <EOL> seld = self . seld <EOL> if type ( seld ) == StringType : <EOL> ss = repr ( seld ) <EOL> elif IsRange ( seld ) : <EOL> start , stop = seld . start , seld . stop <EOL> if type ( start ) == InstanceType == type ( stop ) and start . __class__ == self . __class__ == stop . __class__ : <EOL> ss = str ( start . seld ) + "<STR_LIT>" + str ( stop . seld ) <EOL> else : <EOL> ss = str ( seld ) <EOL> else : <EOL> ss = str ( seld ) <EOL> s = "<STR_LIT>" % ( self . __class__ . __name__ , ss ) <EOL> if self . fr : s = s + "<STR_LIT>" % str ( self . fr ) <EOL> return s <EOL> def __getattr__ ( self , name ) : <EOL> if name in self . _elemdict : <EOL> cls = self . _elemdict [ name ] <EOL> return DelayedComponentItem ( cls , self ) <EOL> if name in self . _propdict : <EOL> cls = self . _propdict [ name ] <EOL> return cls ( self ) <EOL> raise AttributeError , name <EOL> class DelayedComponentItem : <EOL> def __init__ ( self , compclass , fr ) : <EOL> self . compclass = compclass <EOL> self . fr = fr <EOL> def __call__ ( self , which ) : <EOL> return self . compclass ( which , self . fr ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self . fr ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , str ( self . fr ) ) <EOL> template = """<STR_LIT>""" <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT:text>' ) <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT:file>' ) <EOL> exec template % ( "<STR_LIT>" , '<STR_LIT>' ) </s>
