#NEWLINE# def __init__( self , input = None ) : #NEWLINE# #INDENT# if ( None == input ) : #NEWLINE# #INDENT# input = os . path . expanduser ( '~/Library/Safari/Bookmarks.plist' ) #NEWLINE# #UNINDENT# pipe = subprocess . Popen ( ( '/usr/bin/plutil' , '-convert' , 'xml1' , '-o' , '-' , input ) , shell = False , stdout = subprocess . PIPE ) . stdout #NEWLINE# xml = plistlib . readPlist ( pipe ) #NEWLINE# pipe . close ( ) #NEWLINE# section = filter ( ( lambda record : ( 'com.apple.ReadingList' == record . get ( 'Title' ) ) ) , xml [ 'Children' ] ) #NEWLINE# reading_list = section [ 0 ] . get ( 'Children' ) #NEWLINE# if ( None == reading_list ) : #NEWLINE# #INDENT# reading_list = [ ] #NEWLINE# #UNINDENT# self . _articles = [ ] #NEWLINE# for item in reading_list : #NEWLINE# #INDENT# added = item [ 'ReadingList' ] . get ( 'DateAdded' ) #NEWLINE# if ( None == added ) : #NEWLINE# #INDENT# added = datetime . datetime . min #NEWLINE# #UNINDENT# viewed = item [ 'ReadingList' ] . get ( 'DateLastViewed' ) #NEWLINE# if ( None == viewed ) : #NEWLINE# #INDENT# viewed = datetime . datetime . min #NEWLINE# #UNINDENT# fetched = item [ 'ReadingList' ] . get ( 'DateLastFetched' ) #NEWLINE# if ( None == fetched ) : #NEWLINE# #INDENT# fetched = item [ 'ReadingListNonSync' ] . get ( 'DateLastFetched' ) #NEWLINE# if ( None == fetched ) : #NEWLINE# #INDENT# fetched = datetime . datetime . min #NEWLINE# #UNINDENT# #UNINDENT# self . _articles . append ( { #NEWLINE# #INDENT# 'title' : item [ 'URIDictionary' ] [ 'title' ] , #NEWLINE# 'url' : item [ 'URLString' ] , #NEWLINE# 'preview' : item [ 'ReadingList' ] . get ( 'PreviewText' , '' ) , #NEWLINE# 'date' : fetched , #NEWLINE# 'added' : added , #NEWLINE# 'viewed' : viewed , #NEWLINE# 'uuid' : item [ 'WebBookmarkUUID' ] , #NEWLINE# 'synckey' : item [ 'Sync' ] . get ( 'Key' ) , #NEWLINE# 'syncserverid' : item [ 'Sync' ] . get ( 'ServerID' ) , #NEWLINE# #UNINDENT# } )