<s> from Foundation import * <EOL> from AppKit import * <EOL> from ScriptingBridge import * <EOL> from AddressBook import * <EOL> import re <EOL> def as_dump ( obj ) : <EOL> methods = dir ( obj ) <EOL> for x in dir ( object ( ) ) + dir ( NSObject . alloc ( ) . init ( ) ) : <EOL> if x in methods : methods . remove ( x ) <EOL> methods . sort ( ) <EOL> print ( obj . __class__ . __name__ ) <EOL> print ( "<STR_LIT:\n>" . join ( map ( lambda x : "<STR_LIT>" % x , methods ) ) ) <EOL> def as_app ( bundle ) : <EOL> return SBApplication . applicationWithBundleIdentifier_ ( bundle ) <EOL> def print_info ( stuff ) : <EOL> if NSUserDefaults . standardUserDefaults ( ) . boolForKey_ ( "<STR_LIT>" ) : <EOL> print ( stuff ) <EOL> def html_escape ( s ) : <EOL> s = re . sub ( r"<STR_LIT:&>" , "<STR_LIT>" , s ) <EOL> s = re . sub ( r"<STR_LIT:<>" , "<STR_LIT>" , s ) <EOL> s = re . sub ( r"<STR_LIT:>>" , "<STR_LIT>" , s ) <EOL> return s <EOL> def normalize_url ( url ) : <EOL> url = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , url ) <EOL> url = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , url ) <EOL> url = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , url ) <EOL> return url . lower ( ) <EOL> """<STR_LIT>""" <EOL> from datetime import datetime <EOL> import time <EOL> DEFAULT_PREFIX = '<STR_LIT:date>' <EOL> def distance_of_time_in_words ( from_time , to_time = <NUM_LIT:0> , include_seconds = False ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( from_time , int ) : <EOL> from_time = time . time ( ) + from_time <EOL> elif isinstance ( from_time , time . struct_time ) : <EOL> from_time = time . mktime ( from_time ) <EOL> else : <EOL> from_time = time . mktime ( from_time . timetuple ( ) ) <EOL> if isinstance ( to_time , int ) : <EOL> to_time = time . time ( ) + to_time <EOL> else : <EOL> to_time = time . mktime ( to_time . timetuple ( ) ) <EOL> distance_in_minutes = int ( round ( abs ( to_time - from_time ) / <NUM_LIT> ) ) <EOL> distance_in_seconds = int ( round ( abs ( to_time - from_time ) ) ) <EOL> if distance_in_minutes <= <NUM_LIT:1> : <EOL> if include_seconds : <EOL> for remainder in [ <NUM_LIT:5> , <NUM_LIT:10> , <NUM_LIT:20> ] : <EOL> if distance_in_seconds < remainder : <EOL> return "<STR_LIT>" % remainder <EOL> if distance_in_seconds < <NUM_LIT> : <EOL> return "<STR_LIT>" <EOL> elif distance_in_seconds < <NUM_LIT> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> else : <EOL> if distance_in_minutes == <NUM_LIT:0> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> elif distance_in_minutes < <NUM_LIT> : <EOL> return "<STR_LIT>" % distance_in_minutes <EOL> elif distance_in_minutes < <NUM_LIT> : <EOL> return "<STR_LIT>" <EOL> elif distance_in_minutes < <NUM_LIT> : <EOL> return "<STR_LIT>" % ( round ( distance_in_minutes / <NUM_LIT> ) ) <EOL> elif distance_in_minutes < <NUM_LIT> : <EOL> return "<STR_LIT>" <EOL> elif distance_in_minutes < <NUM_LIT> : <EOL> return "<STR_LIT>" % ( round ( distance_in_minutes / <NUM_LIT> ) ) <EOL> elif distance_in_minutes < <NUM_LIT> : <EOL> return "<STR_LIT>" <EOL> elif distance_in_minutes < <NUM_LIT> : <EOL> return "<STR_LIT>" % ( round ( distance_in_minutes / <NUM_LIT> ) ) <EOL> elif distance_in_minutes < <NUM_LIT> : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" % ( round ( distance_in_minutes / <NUM_LIT> ) ) <EOL> def time_ago_in_words ( from_time , include_seconds = False ) : <EOL> """<STR_LIT>""" <EOL> ago = distance_of_time_in_words ( from_time , datetime . utcnow ( ) , include_seconds ) <EOL> ago = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , ago ) <EOL> ago = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , ago ) <EOL> ago = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , ago ) <EOL> return ago <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] </s>
