def get_iphoto_data(album_xml_file, album_sql_file, ratings=None, verbose=False, aperture=False): """reads the iPhoto database and converts it into an iPhotoData object.""" library_dir = os.path.dirname(album_xml_file) is_aperture = aperture or album_xml_file.endswith('ApertureData.xml') if verbose: print "Reading %s database from %s..." % ( 'Aperture' if is_aperture else 'iPhoto', album_xml_file) album_xml = applexml.read_applexml(album_xml_file, album_sql_file) album_xml2 = None if is_aperture: try: import appledata.aperturedata as aperturedata aperture_data = aperturedata.get_aperture_data( library_dir, verbose) except ImportError: aperture_data = None else: aperture_data = None # Recent iPhoto versions write event and album data into # iLifeShared/AlbumData2.xml. album_xml_file2 = os.path.join( os.path.split(album_xml_file)[0], "iLifeShared", "AlbumData2.xml") if os.path.exists(album_xml_file2): if verbose: su.pout("Reading event and album data from %s..." % (album_xml_file2)) album_xml2 = applexml.read_applexml(album_xml_file2, None) application_version = album_xml.get("Application Version") data = IPhotoData(album_xml, album_xml2, ratings, is_aperture, aperture_data) if is_aperture: if (not data.applicationVersion.startswith('3.') and not data.applicationVersion.startswith('9.')): raise ValueError, "Aperture version %s not supported" % ( data.applicationVersion) else: if (not data.applicationVersion.startswith("9.") and not data.applicationVersion.startswith("8.") and not data.applicationVersion.startswith("7.") and not data.applicationVersion.startswith("6.")): raise ValueError, "iPhoto version %s not supported" % ( data.applicationVersion) return data
def get_iphoto_data(album_xml_file, album_sql_file, ratings=None, verbose=False, aperture=False): """reads the iPhoto database and converts it into an iPhotoData object.""" library_dir = os.path.dirname(album_xml_file) is_aperture = aperture or album_xml_file.endswith('ApertureData.xml') if verbose: print "Reading %s database from %s..." % ( 'Aperture' if is_aperture else 'iPhoto', album_xml_file) album_xml = applexml.read_applexml(album_xml_file, album_sql_file) album_xml2 = None if is_aperture: try: import appledata.aperturedata as aperturedata aperture_data = aperturedata.get_aperture_data(library_dir, verbose) except ImportError: aperture_data = None else: aperture_data = None # Recent iPhoto versions write event and album data into # iLifeShared/AlbumData2.xml. album_xml_file2 = os.path.join(os.path.split(album_xml_file)[0], "iLifeShared", "AlbumData2.xml") if os.path.exists(album_xml_file2): if verbose: su.pout("Reading event and album data from %s..." % (album_xml_file2)) album_xml2 = applexml.read_applexml(album_xml_file2, None) application_version = album_xml.get("Application Version") data = IPhotoData(album_xml, album_xml2, ratings, is_aperture, aperture_data) if is_aperture: if (not data.applicationVersion.startswith('3.') and not data.applicationVersion.startswith('9.')): raise ValueError, "Aperture version %s not supported" % ( data.applicationVersion) else: if (not data.applicationVersion.startswith("9.") and not data.applicationVersion.startswith("8.") and not data.applicationVersion.startswith("7.") and not data.applicationVersion.startswith("6.")): raise ValueError, "iPhoto version %s not supported" % ( data.applicationVersion) return data
def get_iphoto_data(album_xml_file): """reads the iPhoto database and converts it into an iPhotoData object.""" library_dir = os.path.dirname(album_xml_file) print "Reading iPhoto database from " + library_dir + "..." album_xml = applexml.read_applexml(album_xml_file) data = IPhotoData(album_xml, album_xml_file.endswith('ApertureData.xml')) if data.aperture: if not data.applicationVersion.startswith('3.'): raise ValueError, "Aperture version %s not supported" % ( data.applicationVersion) else: if (not data.applicationVersion.startswith("9.") and not data.applicationVersion.startswith("8.") and not data.applicationVersion.startswith("7.") and not data.applicationVersion.startswith("6.")): raise ValueError, "iPhoto version %s not supported" % ( data.applicationVersion) return data