2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								""" Utility routines depending on the finder, 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								a  combination  of  code  by  Jack  Jansen  and  erik @letterror.com .  
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Most  events  have  been  captured  from  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Lasso  Capture  AE  and  than  translated  to  python  code .  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								IMPORTANT  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note  that  the  processes ( )  function  returns  different  values  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								depending  on  the  OS  version  it  is  running  on .  On  MacOS  9  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the  Finder  returns  the  process  * names *  which  can  then  be  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								used  to  find  out  more  about  them .  On  MacOS  8.6  and  earlier  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the  Finder  returns  a  code  which  does  not  seem  to  work .  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								So  bottom  line :  the  processes ( )  stuff  does  not  work  on  <  MacOS9  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Mostly  written  by  erik @letterror.com  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								""" 
  
						 
					
						
							
								
									
										
										
										
											2008-05-12 21:42:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								from  warnings  import  warnpy3k  
						 
					
						
							
								
									
										
										
										
											2008-07-14 17:42:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								warnpy3k ( " In 3.x, the findertools module is removed. " ,  stacklevel = 2 )  
						 
					
						
							
								
									
										
										
										
											2008-05-12 21:42:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2000-08-20 19:56:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  Finder  
						 
					
						
							
								
									
										
										
										
											2001-08-25 12:15:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  Carbon  import  AppleEvents  
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import  aetools  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  MacOS  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  sys  
						 
					
						
							
								
									
										
										
										
											2003-02-21 23:14:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  Carbon . File  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  Carbon . Folder  
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  aetypes  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								from  types  import  *  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								__version__  =  ' 1.1 '  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Error  =  ' findertools.Error '  
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								_finder_talker  =  None  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  _getfinder ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ returns basic (recyclable) Finder AE interface object """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    global  _finder_talker 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  _finder_talker : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        _finder_talker  =  Finder . Finder ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    _finder_talker . send_flags  =  (  _finder_talker . send_flags  | 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        AppleEvents . kAECanInteract  |  AppleEvents . kAECanSwitchLayer ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  _finder_talker 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								def  launch ( file ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Open a file thru the finder. Specify file by name or fsspec """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fss  =  Carbon . File . FSSpec ( file ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  finder . open ( fss ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								def  Print ( file ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Print a file thru the finder. Specify file by name or fsspec """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fss  =  Carbon . File . FSSpec ( file ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  finder . _print ( fss ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								def  copy ( src ,  dstdir ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Copy a file to a folder """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  type ( src )  ==  type ( [ ] ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        src_fss  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  s  in  src : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            src_fss . append ( Carbon . File . FSSpec ( s ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        src_fss  =  Carbon . File . FSSpec ( src ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    dst_fss  =  Carbon . File . FSSpec ( dstdir ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  finder . duplicate ( src_fss ,  to = dst_fss ) 
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  move ( src ,  dstdir ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Move a file to a folder """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  type ( src )  ==  type ( [ ] ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        src_fss  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  s  in  src : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            src_fss . append ( Carbon . File . FSSpec ( s ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        src_fss  =  Carbon . File . FSSpec ( src ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    dst_fss  =  Carbon . File . FSSpec ( dstdir ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  finder . move ( src_fss ,  to = dst_fss ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								def  sleep ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Put the mac to sleep """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder . sleep ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								def  shutdown ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Shut the mac down """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder . shut_down ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								def  restart ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Restart the mac """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder . restart ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#---------------------------------------------------  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#   Additional findertools  
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  reveal ( file ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Reveal a file in the finder. Specify file by name, fsref or fsspec. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fsr  =  Carbon . File . FSRef ( file ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    file_alias  =  fsr . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  finder . reveal ( file_alias ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  select ( file ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ select a file in the finder. Specify file by name, fsref or fsspec. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fsr  =  Carbon . File . FSRef ( file ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    file_alias  =  fsr . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  finder . select ( file_alias ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  update ( file ) :  
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Update the display of the specified object(s) to match 
 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    their  on - disk  representation .  Specify  file  by  name ,  fsref  or  fsspec . """ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fsr  =  Carbon . File . FSRef ( file ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    file_alias  =  fsr . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  finder . update ( file_alias ) 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#---------------------------------------------------  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#   More findertools  
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  comment ( object ,  comment = None ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ comment: get or set the Finder-comment of the item, displayed in the  ' Get Info '  window. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object  =  Carbon . File . FSRef ( object ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object_alias  =  object . FSNewAliasMonimal ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-29 15:24:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  comment  is  None : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  _getcomment ( object_alias ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  _setcomment ( object_alias ,  comment ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _setcomment ( object_alias ,  comment ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cobj ' ) ,  form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' comt ' ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_01 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ " data " ]  =  comment 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " setd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  _getcomment ( object_alias ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cobj ' ) ,  form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' comt ' ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_01 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#---------------------------------------------------  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#   Get information about current processes in the Finder.  
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  processes ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ processes returns a list of all active processes running on this computer and their creators. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    processnames  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    processnumbers  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    creators  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    partitions  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    used  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ## get the processnames or else the processnumbers 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prcs ' ) ,  form = " indx " ,  seld = aetypes . Unknown ( ' abso ' ,  " all  " ) ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( ' core ' ,  ' getd ' ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p  =  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        p  =   args [ ' ---- ' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  proc  in  p : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  hasattr ( proc ,  ' seld ' ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                # it has a real name 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                processnames . append ( proc . seld ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            elif  hasattr ( proc ,  ' type ' ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  proc . type  ==  " psn  " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    # it has a process number 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    processnumbers . append ( proc . data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ## get the creators 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prcs ' ) ,  form = " indx " ,  seld = aetypes . Unknown ( ' abso ' ,  " all  " ) ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =   aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' fcrt ' ) ,  fr = aeobj_0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( ' core ' ,  ' getd ' ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( _arg ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        p  =   args [ ' ---- ' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        creators  =  p [ : ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ## concatenate in one dict 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    result  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  len ( processnames )  >  len ( processnumbers ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        data  =  processnames 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        data  =  processnumbers 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  i  in  range ( len ( creators ) ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        result . append ( ( data [ i ] ,  creators [ i ] ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  result 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  _process :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    pass 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  isactiveprocess ( processname ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Check of processname is active. MacOS9 """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    all  =  processes ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ok  =  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  n ,  c  in  all : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  n  ==  processname : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  0 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  processinfo ( processname ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Return an object with all process properties as attributes for processname. MacOS9 """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p  =  _process ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  processname  ==  " Finder " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        p . partition  =  None 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        p . used  =  None 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        p . partition  =  _processproperty ( processname ,  ' appt ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        p . used  =  _processproperty ( processname ,  ' pusd ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p . visible  =  _processproperty ( processname ,  ' pvis ' )        #Is the process' layer visible? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p . frontmost  =  _processproperty ( processname ,  ' pisf ' )  #Is the process the frontmost process? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p . file  =  _processproperty ( processname ,  ' file ' )           #the file from which the process was launched 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p . filetype   =  _processproperty ( processname ,  ' asty ' )      #the OSType of the file type of the process 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p . creatortype  =  _processproperty ( processname ,  ' fcrt ' )    #the OSType of the creator of the process (the signature) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p . accepthighlevel  =  _processproperty ( processname ,  ' revt ' )    #Is the process high-level event aware (accepts open application, open document, print document, and quit)? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    p . hasscripting  =  _processproperty ( processname ,  ' hscr ' )       #Does the process have a scripting terminology, i.e., can it be scripted? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  p 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _processproperty ( processname ,  property ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ return the partition size and memory used for processname """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prcs ' ) ,  form = " name " ,  seld = processname ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( property ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_01 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#---------------------------------------------------  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#   Mess around with Finder windows.  
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  openwindow ( object ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Open a Finder window for object, Specify object by name or fsspec. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object  =  Carbon . File . FSRef ( object ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object_alias  =  object . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _code  =  ' aevt ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _subcode  =  ' odoc ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) ,  form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( _code ,  _subcode ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  closewindow ( object ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Close a Finder window for folder, Specify by path. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object  =  Carbon . File . FSRef ( object ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object_alias  =  object . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _code  =  ' core ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _subcode  =  ' clos ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) ,  form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( _code ,  _subcode ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  location ( object ,  pos = None ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Set the position of a Finder window for folder to pos=(w, h). Specify file by name or fsspec. 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    If  pos = None ,  location  will  return  the  current  position  of  the  object . """ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object  =  Carbon . File . FSRef ( object ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object_alias  =  object . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  pos : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  _getlocation ( object_alias ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  _setlocation ( object_alias ,  pos ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _setlocation ( object_alias ,  ( x ,  y ) ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ _setlocation: Set the location of the icon for the object. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) ,  form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' posn ' ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_01 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ " data " ]  =  [ x ,  y ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " setd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  ( x , y ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _getlocation ( object_alias ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ _getlocation: get the location of the icon for the object. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) ,  form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' posn ' ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_01 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        pos  =  args [ ' ---- ' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  pos . h ,  pos . v 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  label ( object ,  index = None ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ label: set or get the label of the item. Specify file by name or fsspec. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object  =  Carbon . File . FSRef ( object ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object_alias  =  object . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-29 15:24:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  index  is  None : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  _getlabel ( object_alias ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  index  <  0  or  index  >  7 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        index  =  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  _setlabel ( object_alias ,  index ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _getlabel ( object_alias ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ label: Get the label for the object. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cobj ' ) ,  form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' labi ' ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_01 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  _setlabel ( object_alias ,  index ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ label: Set the label for the object. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _code  =  ' core ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _subcode  =  ' setd ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_1  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' labi ' ) ,  fr = aeobj_0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ " data " ]  =  index 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( _code ,  _subcode ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  index 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  windowview ( folder ,  view = None ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ windowview: Set the view of the window for the folder. Specify file by name or fsspec. 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    0  =  by  icon  ( default ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    1  =  by  name 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    2  =  by  button 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    """ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fsr  =  Carbon . File . FSRef ( folder ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    folder_alias  =  fsr . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-29 15:24:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  view  is  None : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  _getwindowview ( folder_alias ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  _setwindowview ( folder_alias ,  view ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _setwindowview ( folder_alias ,  view = 0 ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ set the windowview """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  view  ==  1 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        _v  =  aetypes . Type ( ' pnam ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    elif  view  ==  2 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        _v  =  aetypes . Type ( ' lgbu ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        _v  =  aetypes . Type ( ' iimg ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want  =  aetypes . Type ( ' cfol ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form  =  ' alis ' ,  seld  =  folder_alias ,  fr = None ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_1  =  aetypes . ObjectSpecifier ( want  =  aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form  =  ' prop ' ,  seld  =  aetypes . Type ( ' cwnd ' ) ,  fr = aeobj_0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_2  =  aetypes . ObjectSpecifier ( want  =  aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form  =  ' prop ' ,  seld  =  aetypes . Type ( ' pvew ' ) ,  fr = aeobj_1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_3  =  aetypes . ObjectSpecifier ( want  =  aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form  =  ' prop ' ,  seld  =  _v ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _code  =  ' core ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _subcode  =  ' setd ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' data ' ]  =  aeobj_3 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( _code ,  _subcode ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  _getwindowview ( folder_alias ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ get the windowview """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) ,  form = " alis " ,  seld = folder_alias ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' cwnd ' ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_02  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' pvew ' ) ,  fr = aeobj_01 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_02 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    views  =  { ' iimg ' : 0 ,  ' pnam ' : 1 ,  ' lgbu ' : 2 } 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  views [ args [ ' ---- ' ] . enum ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  windowsize ( folder ,  size = None ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Set the size of a Finder window for folder to size=(w, h), Specify by path. 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    If  size = None ,  windowsize  will  return  the  current  size  of  the  window . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Specify  file  by  name  or  fsspec . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    """ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fsr  =  Carbon . File . FSRef ( folder ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    folder_alias  =  fsr . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    openwindow ( fsr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  size : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  _getwindowsize ( folder_alias ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  _setwindowsize ( folder_alias ,  size ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _setwindowsize ( folder_alias ,  ( w ,  h ) ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Set the size of a Finder window for folder to (w, h) """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _code  =  ' core ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _subcode  =  ' setd ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aevar00  =  [ w ,  h ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            form = " alis " ,  seld = folder_alias ,  fr = None ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_1  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' cwnd ' ) ,  fr = aeobj_0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_2  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' ptsz ' ) ,  fr = aeobj_1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ " data " ]  =  aevar00 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( _code ,  _subcode ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  ( w ,  h ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _getwindowsize ( folder_alias ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Set the size of a Finder window for folder to (w, h) """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " alis " ,  seld = folder_alias ,  fr = None ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_1  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' cwnd ' ) ,  fr = aeobj_0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_2  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' posn ' ) ,  fr = aeobj_1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( ' core ' ,  ' getd ' ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  windowposition ( folder ,  pos = None ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Set the position of a Finder window for folder to pos=(w, h). """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fsr  =  Carbon . File . FSRef ( folder ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    folder_alias  =  fsr . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    openwindow ( fsr ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  pos : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  _getwindowposition ( folder_alias ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  type ( pos )  ==  InstanceType : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # pos might be a QDPoint object as returned by _getwindowposition 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        pos  =  ( pos . h ,  pos . v ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  _setwindowposition ( folder_alias ,  pos ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _setwindowposition ( folder_alias ,  ( x ,  y ) ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Set the size of a Finder window for folder to (w, h). """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " alis " ,  seld = folder_alias ,  fr = None ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_1  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' cwnd ' ) ,  fr = aeobj_0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_2  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' posn ' ) ,  fr = aeobj_1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ " data " ]  =  [ x ,  y ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( ' core ' ,  ' setd ' ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  _getwindowposition ( folder_alias ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Get the size of a Finder window for folder, Specify by path. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_0  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cfol ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " alis " ,  seld = folder_alias ,  fr = None ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_1  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' cwnd ' ) ,  fr = aeobj_0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_2  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' ptsz ' ) ,  fr = aeobj_1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( ' core ' ,  ' getd ' ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  icon ( object ,  icondata = None ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ icon sets the icon of object, if no icondata is given, 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    icon  will  return  an  AE  object  with  binary  data  for  the  current  icon . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    If  left  untouched ,  this  data  can  be  used  to  paste  the  icon  on  another  file . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Development  opportunity :  get  and  set  the  data  as  PICT . """ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fsr  =  Carbon . File . FSRef ( object ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object_alias  =  fsr . FSNewAliasMinimal ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-29 15:24:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  icondata  is  None : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  _geticon ( object_alias ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  _seticon ( object_alias ,  icondata ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _geticon ( object_alias ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ get the icondata for object. Binary data of some sort. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cobj ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' iimg ' ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_01 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  _seticon ( object_alias ,  icondata ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ set the icondata for object, formatted as produced by _geticon() """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cobj ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " alis " ,  seld = object_alias ,  fr = None ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    aeobj_01  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form = " prop " ,  seld = aetypes . Type ( ' iimg ' ) ,  fr = aeobj_00 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_01 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ " data " ]  =  icondata 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " setd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] . data 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#---------------------------------------------------  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#   Volumes and servers.  
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  mountvolume ( volume ,  server = None ,  username = None ,  password = None ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ mount a volume, local or on a server on AppleTalk. 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Note :  mounting  a  ASIP  server  requires  a  different  operation . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    server  is  the  name  of  the  server  where  the  volume  belongs 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    username ,  password  belong  to  a  registered  user  of  the  volume . """ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  password : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        args [ " PASS " ]  =  password 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  username : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        args [ " USER " ]  =  username 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  server : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        args [ " SRVR " ]  =  server 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  volume 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " aevt " ,  " mvol " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  unmountvolume ( volume ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ unmount a volume that ' s on the desktop """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    putaway ( volume ) 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  putaway ( object ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ puth the object away, whereever it came from. """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' cdis ' ) ,  form = " name " ,  seld = object ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  talker . send ( " fndr " ,  " ptwy " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#---------------------------------------------------  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#   Miscellaneous functions  
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  volumelevel ( level ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ set the audio output level, parameter between 0 (silent) and 7 (full blast) """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  level  <  0 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        level  =  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    elif  level  >  7 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        level  =  7 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  level 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " aevt " ,  " stvl " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  OSversion ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ return the version of the system software """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    aeobj_00  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' ver2 ' ) ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aeobj_00 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  args [ ' ---- ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  filesharing ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ return the current status of filesharing and whether it is starting up or not: 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        - 1   file  sharing  is  off  and  not  starting  up 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        0    file  sharing  is  off  and  starting  up 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        1    file  sharing  is  on """ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    status  =  - 1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # see if it is on 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' fshr ' ) ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  args [ ' ---- ' ]  ==  0 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            status  =  - 1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            status  =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # is it starting up perchance? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' fsup ' ) ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " core " ,  " getd " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' ---- '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  args [ ' ---- ' ]  ==  1 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            status  =  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  status 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  movetotrash ( path ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ move the object to the trash """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    fss  =  Carbon . File . FSSpec ( path ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    trashfolder  =  Carbon . Folder . FSFindFolder ( fss . as_tuple ( ) [ 0 ] ,  ' trsh ' ,  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    move ( path ,  trashfolder ) 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  emptytrash ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ empty the trash """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    finder  =  _getfinder ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    attrs  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args [ ' ---- ' ]  =  aetypes . ObjectSpecifier ( want = aetypes . Type ( ' prop ' ) ,  form = " prop " ,  seld = aetypes . Type ( ' trsh ' ) ,  fr = None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _reply ,  args ,  attrs  =  finder . send ( " fndr " ,  " empt " ,  args ,  attrs ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-03 18:17:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' errn '  in  args : 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  aetools . Error ,  aetools . decodeerror ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  _test ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    import  EasyDialogs 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Original findertools functionality test... ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Testing launch... ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pathname  =  EasyDialogs . AskFileForOpen ( ' File to launch: ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  pathname : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        result  =  launch ( pathname ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  result : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print  ' Result:  ' ,  result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print  ' Press return- ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sys . stdin . readline ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Testing print... ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pathname  =  EasyDialogs . AskFileForOpen ( ' File to print: ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  pathname : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        result  =  Print ( pathname ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  result : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print  ' Result:  ' ,  result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print  ' Press return- ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sys . stdin . readline ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Testing copy... ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pathname  =  EasyDialogs . AskFileForOpen ( ' File to copy: ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  pathname : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        destdir  =  EasyDialogs . AskFolder ( ' Destination: ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  destdir : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            result  =  copy ( pathname ,  destdir ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  result : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                print  ' Result: ' ,  result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print  ' Press return- ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            sys . stdin . readline ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Testing move... ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pathname  =  EasyDialogs . AskFileForOpen ( ' File to move: ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  pathname : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        destdir  =  EasyDialogs . AskFolder ( ' Destination: ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  destdir : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            result  =  move ( pathname ,  destdir ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  result : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                print  ' Result: ' ,  result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print  ' Press return- ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            sys . stdin . readline ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Testing sleep... ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  EasyDialogs . AskYesNoCancel ( ' Sleep? ' )  >  0 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        result  =  sleep ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  result : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print  ' Result: ' ,  result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print  ' Press return- ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sys . stdin . readline ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Testing shutdown... ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  EasyDialogs . AskYesNoCancel ( ' Shut down? ' )  >  0 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        result  =  shutdown ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  result : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print  ' Result: ' ,  result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print  ' Press return- ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sys . stdin . readline ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Testing restart... ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  EasyDialogs . AskYesNoCancel ( ' Restart? ' )  >  0 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        result  =  restart ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  result : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print  ' Result: ' ,  result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print  ' Press return- ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sys . stdin . readline ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  _test2 ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    print  ' \n morefindertools version  %s \n Tests coming up... '  % __version__ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    import  os 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    import  random 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # miscellaneous 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t filesharing on? ' ,   filesharing ( )        # is file sharing on, off, starting up? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t OS version ' ,        OSversion ( )      # the version of the system software 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # set the soundvolume in a simple way 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t System beep volume ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  i  in  range ( 0 ,  7 ) : 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        volumelevel ( i ) 
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        MacOS . SysBeep ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Finder's windows, file location, file attributes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    open ( " @findertoolstest " ,  " w " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    f  =  " @findertoolstest " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    reveal ( f )                # reveal this file in a Finder window 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    select ( f )                # select this file 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    base ,  file  =  os . path . split ( f ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    closewindow ( base )    # close the window this file is in  (opened by reveal) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    openwindow ( base )         # open it again 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    windowview ( base ,  1 )  # set the view by list 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    label ( f ,  2 )              # set the label of this file to something orange 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t label ' ,  label ( f )    # get the label of this file 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # the file location only works in a window with icon view! 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Random locations for an icon ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    windowview ( base ,  0 )      # set the view by icon 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    windowsize ( base ,  ( 600 ,  600 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  i  in  range ( 50 ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        location ( f ,  ( random . randint ( 10 ,  590 ) ,  random . randint ( 10 ,  590 ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    windowsize ( base ,  ( 200 ,  400 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    windowview ( base ,  1 )      # set the view by icon 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    orgpos  =  windowposition ( base ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Animated window location ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  i  in  range ( 10 ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        pos  =  ( 100 + i * 10 ,  100 + i * 10 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        windowposition ( base ,  pos ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print  ' \t window position ' ,  pos 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    windowposition ( base ,  orgpos )     # park it where it was before 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Put a comment in file ' ,  f ,  ' : ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t ' ,  comment ( f )       # print the Finder comment this file has 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    s  =  ' This is a comment no one reads! ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    comment ( f ,  s )            # set the Finder comment 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  _test3 ( ) :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    print  ' MacOS9 or better specific functions ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # processes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pr  =  processes ( )         # return a list of tuples with (active_processname, creatorcode) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Return a list of current active processes: ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  p  in  pr : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print  ' \t ' ,  p 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-18 06:16:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # get attributes of the first process in the list 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' Attributes of the first process in the list: ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pinfo  =  processinfo ( pr [ 0 ] [ 0 ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t ' ,  pr [ 0 ] [ 0 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t \t memory partition ' ,  pinfo . partition        # the memory allocated to this process 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t \t memory used ' ,  pinfo . used          # the memory actuall used by this process 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t \t is visible ' ,  pinfo . visible            # is the process visible to the user 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t \t is frontmost ' ,  pinfo . frontmost        # is the process the front most one? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t \t has scripting ' ,  pinfo . hasscripting        # is the process scriptable? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print  ' \t \t accepts high level events ' ,   pinfo . accepthighlevel    # does the process accept high level appleevents? 
							 
						 
					
						
							
								
									
										
										
										
											2001-04-07 12:53:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											1996-09-20 15:26:20 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								if  __name__  ==  ' __main__ ' :  
						 
					
						
							
								
									
										
										
										
											2003-04-09 13:25:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    _test ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _test2 ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _test3 ( )