How to use the osxphotos.placeinfo.PlaceInfo function in osxphotos

To help you get started, we’ve selected a few osxphotos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RhetTbull / osxphotos / tests / test_places_catalina_10_15_1.py View on Github external
def test_place_place_info_2():
    # test valid place info
    import osxphotos

    photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
    photo = photosdb.photos(uuid=[UUID_DICT["place_maui"]])[0]

    assert isinstance(photo.place, osxphotos.placeinfo.PlaceInfo)
    assert photo.place is not None
    assert not photo.place.ishome
    assert photo.place.name == "Maui, Wailea, Hawai'i, United States"
    assert photo.place.names.street_address == ["3700 Wailea Alanui Dr"]
    assert photo.place.names.city == ["Wailea", "Kihei", "Kihei"]
    assert photo.place.names.region == ["Maui"]
    assert photo.place.names.sub_administrative_area == ["Maui"]
    assert photo.place.names.state_province == ["Hawai'i"]
    assert photo.place.names.country == ["United States"]

    assert photo.place.country_code == "US"
    assert (
        photo.place.address_str
        == "3700 Wailea Alanui Dr, Kihei, HI  96753, United States"
    )
    assert type(photo.place.address) == osxphotos.placeinfo.PostalAddress
github RhetTbull / osxphotos / tests / test_places_high_sierra_10_13_6.py View on Github external
def test_place_place_info_1():
    # test valid place info
    import osxphotos

    photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
    photo = photosdb.photos(uuid=[UUID_DICT["place_dc"]])[0]
    assert photo.place is not None
    assert isinstance(photo.place, osxphotos.placeinfo.PlaceInfo)
    assert not photo.place.ishome
    assert photo.place.name == "Washington, District of Columbia, United States"
    assert photo.place.names.country == ["United States"]
    assert photo.place.names.state_province == ["District of Columbia"]
    assert photo.place.names.sub_administrative_area == []
    assert photo.place.names.city == ["Washington"]
    assert photo.place.names.additional_city_info == []
    assert photo.place.names.ocean == []
    assert photo.place.names.area_of_interest == []
    assert photo.place.names.inland_water == []
    assert photo.place.names.region == []
    assert photo.place.names.postal_code == []
    assert photo.place.names.street_address == []
    assert photo.place.names.sub_throughfare == []
    assert photo.place.names.body_of_water == []
github RhetTbull / osxphotos / tests / test_places_mojave_10_14_6.py View on Github external
def test_place_as_dict():
    # test PlaceInfo.as_dict()
    import osxphotos

    photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
    photo = photosdb.photos(uuid=[UUID_DICT["place_uk"]])[0]
    assert photo.place is not None
    assert isinstance(photo.place, osxphotos.placeinfo.PlaceInfo)
    assert photo.place.as_dict() == UK_DICT
github RhetTbull / osxphotos / tests / test_places_high_sierra_10_13_6.py View on Github external
def test_place_place_info_2():
    # test valid place info with only 2 names of info
    import osxphotos

    photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
    photo = photosdb.photos(uuid=[UUID_DICT["place_2_names"]])[0]
    assert photo.place is not None
    assert isinstance(photo.place, osxphotos.placeinfo.PlaceInfo)
    assert not photo.place.ishome
    assert photo.place.name == "Artibonite, Haiti"
    assert photo.place.names.country == ["Haiti"]
    assert photo.place.names.state_province == ["Artibonite"]
    assert photo.place.names.sub_administrative_area == []
    assert photo.place.names.city == []
    assert photo.place.names.additional_city_info == []
    assert photo.place.names.ocean == []
    assert photo.place.names.area_of_interest == []
    assert photo.place.names.inland_water == []
    assert photo.place.names.region == []
    assert photo.place.names.postal_code == []
    assert photo.place.names.street_address == []
    assert photo.place.names.sub_throughfare == []
    assert photo.place.names.body_of_water == ["Caribbean Sea"]
github RhetTbull / osxphotos / tests / test_places_catalina_10_15_1.py View on Github external
def test_place_place_info_1():
    # test valid place info
    import osxphotos

    photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
    photo = photosdb.photos(uuid=[UUID_DICT["place_dc"]])[0]
    assert photo.place is not None
    assert isinstance(photo.place, osxphotos.placeinfo.PlaceInfo)
    assert not photo.place.ishome
    assert photo.place.name == "Washington, District of Columbia, United States"
    assert photo.place.names.country[0] == "United States"
    assert photo.place.names.state_province[0] == "District of Columbia"
    assert photo.place.names.city[0] == "Washington"
    assert photo.place.names.additional_city_info[0] == "Adams Morgan"
    assert photo.place.names.street_address[0] == "2038 18th St NW"
    assert photo.place.names.ocean == []
    assert photo.place.names.area_of_interest == []
    assert photo.place.names.inland_water == []
    assert photo.place.names.postal_code == []
    assert photo.place.names.sub_throughfare == []
    assert photo.place.names.body_of_water == []

    assert photo.place.country_code == "US"
    assert (
github RhetTbull / osxphotos / tests / test_placeinfo.py View on Github external
# test PLRevGeoLocationInfo class archive/unarchive
    from bpylist import archiver
    from osxphotos.placeinfo import (
        PlaceInfo,
        PlaceInfo5,
        PLRevGeoLocationInfo,
        CNPostalAddress,
        PLRevGeoMapItem,
        PLRevGeoMapItemAdditionalPlaceInfo,
    )

    place_1 = PlaceInfo5(REVERSE_GEO_LOC_DATA_1)
    plrevgeoloc_1 = place_1._plrevgeoloc
    archived = archiver.archive(plrevgeoloc_1)
    place_1_unarchived = PlaceInfo5(archived)
    assert isinstance(place_1_unarchived, PlaceInfo)
    assert place_1_unarchived._plrevgeoloc == place_1._plrevgeoloc
github RhetTbull / osxphotos / tests / test_places_mojave_10_14_6.py View on Github external
def test_place_place_info_1():
    # test valid place info
    import osxphotos

    photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
    photo = photosdb.photos(uuid=[UUID_DICT["place_uk"]])[0]
    assert photo.place is not None
    assert isinstance(photo.place, osxphotos.placeinfo.PlaceInfo)
    assert not photo.place.ishome
    assert photo.place.name == "St James's Park, Westminster, United Kingdom"
    assert photo.place.names.area_of_interest == ["St James's Park"]
    assert photo.place.names.city == ["Westminster"]
    assert photo.place.names.sub_administrative_area == ["London"]
    assert photo.place.names.state_province == ["England"]
    assert photo.place.names.country == ["United Kingdom"]

    assert photo.place.country_code == "GB"
    assert photo.place.address_str is None
    assert photo.place.address.city is None
    assert photo.place.address.country is None
    assert photo.place.address.postal_code is None
    assert photo.place.address.state_province is None
    assert photo.place.address.street is None
    assert photo.place.address.sub_administrative_area is None
github RhetTbull / osxphotos / tests / test_placeinfo.py View on Github external
def test_placeInfo4():
    # test valid place data info returns a PlaceInfo object
    from osxphotos.placeinfo import PlaceInfo4, PlaceInfo

    place = PlaceInfo4(PLACE_4_INFO_1, PLACE_4_COUNTRY_1)
    assert place is not None
    assert isinstance(place, PlaceInfo)
    assert place.name == "St James's Park, Westminster, United Kingdom"
    assert place.names.city == ["Westminster"]
    assert place.names.country == ["United Kingdom"]
    assert place.names.area_of_interest == ["St James's Park"]
    assert place.names.state_province == ["England"]
    assert place.names.sub_administrative_area == ["London"]
    assert place.names.region == []
    assert place.country_code == "GB"
    assert place.address_str is None
    assert place.address.city is None
    assert place.address.country is None
    assert place.address.postal_code is None
    assert place.address.state_province is None
    assert place.address.street is None
    assert place.address.sub_administrative_area is None
    assert place.address.sub_locality is None
github RhetTbull / osxphotos / osxphotos / placeinfo.py View on Github external
info = {
            "name": self.name,
            "names": self.names,
            "country_code": self.country_code,
        }
        return "PlaceInfo(" + ", ".join([f"{k}='{v}'" for k, v in info.items()]) + ")"

    def as_dict(self):
        return {
            "name": self.name,
            "names": self.names._asdict(),
            "country_code": self.country_code,
        }


class PlaceInfo5(PlaceInfo):
    """ Reverse geolocation place info for a photo (Photos >= 5) """

    def __init__(self, revgeoloc_bplist):
        """ revgeoloc_bplist: a binary plist blob containing 
                a serialized PLRevGeoLocationInfo object """
        self._bplist = revgeoloc_bplist
        self._plrevgeoloc = archiver.unarchive(revgeoloc_bplist)
        self._process_place_info()

    @property
    def address_str(self):
        """ returns the postal address as a string """
        return self._plrevgeoloc.addressString

    @property
    def country_code(self):
github RhetTbull / osxphotos / osxphotos / placeinfo.py View on Github external
    @abstractmethod
    def name(self):
        pass

    @property
    @abstractmethod
    def names(self):
        pass

    @property
    @abstractmethod
    def address(self):
        pass


class PlaceInfo4(PlaceInfo):
    """ Reverse geolocation place info for a photo (Photos <= 4) """

    def __init__(self, place_names, country_code):
        """ place_names: list of place name tuples in ascending order by area 
            tuple fields are: modelID, place name, place type, area, e.g.
            [(5, "St James's Park", 45, 0), 
            (4, 'Westminster', 16, 22097376), 
            (3, 'London', 4, 1596146816), 
            (2, 'England', 2, 180406091776), 
            (1, 'United Kingdom', 1, 414681432064)] 
            country_code: two letter country code for the country
        """
        self._place_names = place_names
        self._country_code = country_code
        self._process_place_info()