Moved PhotosDB attributes to properties instead of methods
This commit is contained in:
216
README.md
216
README.md
@@ -3,58 +3,6 @@
|
|||||||
[](https://github.com/python/black)
|
[](https://github.com/python/black)
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
- [OSXPhotos](#osxphotos)
|
|
||||||
* [What is osxphotos?](#what-is-osxphotos)
|
|
||||||
* [Supported operating systems](#supported-operating-systems)
|
|
||||||
* [Installation instructions](#installation-instructions)
|
|
||||||
* [Command Line Usage](#command-line-usage)
|
|
||||||
* [Example uses of the module](#example-uses-of-the-module)
|
|
||||||
* [Module Interface](#module-interface)
|
|
||||||
+ [PhotosDB](#photosdb)
|
|
||||||
- [Open the default Photos library](#open-the-default-photos-library)
|
|
||||||
- [Open System Photos library](#open-system-photos-library)
|
|
||||||
- [Open a specific Photos library](#open-a-specific-photos-library)
|
|
||||||
- [```keywords()```](#keywords)
|
|
||||||
- [```albums()```](#albums)
|
|
||||||
- [```persons()```](#persons)
|
|
||||||
- [```keywords_as_dict()```](#keywords_as_dict)
|
|
||||||
- [```persons_as_dict()```](#persons_as_dict)
|
|
||||||
- [```albums_as_dict()```](#albums_as_dict)
|
|
||||||
- [```get_library_path()```](#get_library_path)
|
|
||||||
- [```get_db_path()```](#get_db_path)
|
|
||||||
- [```get_db_version()```](#get_db_version)
|
|
||||||
- [`photos(keywords=[], uuid=[], persons=[], albums=[])`](#photoskeywords-uuid-persons-albums)
|
|
||||||
+ [PhotoInfo](#photoinfo)
|
|
||||||
- [`uuid()`](#uuid)
|
|
||||||
- [`filename()`](#filename)
|
|
||||||
- [`original_filename()`](#original_filename)
|
|
||||||
- [`date()`](#date)
|
|
||||||
- [`description()`](#description)
|
|
||||||
- [`title()`](#title)
|
|
||||||
- [`keywords()`](#keywords)
|
|
||||||
- [`albums()`](#albums)
|
|
||||||
- [`persons()`](#persons)
|
|
||||||
- [`path()`](#path)
|
|
||||||
- [`path_edited()`](#path_edited)
|
|
||||||
- [`ismissing()`](#ismissing)
|
|
||||||
- [`hasadjustments()`](#hasadjustments)
|
|
||||||
- [`external_edit()`](#external_edit)
|
|
||||||
- [`favorite()`](#favorite)
|
|
||||||
- [`hidden()`](#hidden)
|
|
||||||
- [`location()`](#location)
|
|
||||||
- [`json()`](#json)
|
|
||||||
- [`export(dest, *filename, edited=False, overwrite=False, increment=True)`](#exportdest-filename-editedfalse-overwritefalse-incrementtrue)
|
|
||||||
+ [Utility Functions](#utility-functions)
|
|
||||||
- [```get_system_library_path()```](#get_system_library_path)
|
|
||||||
- [```get_last_library_path()```](#get_last_library_path)
|
|
||||||
- [```list_photo_libraries()```](#list_photo_libraries)
|
|
||||||
- [```dd_to_dms_str(lat, lon)```](#dd_to_dms_strlat-lon)
|
|
||||||
+ [Examples](#examples)
|
|
||||||
* [History](#history)
|
|
||||||
* [Contributing](#contributing)
|
|
||||||
* [Implementation Notes](#implementation-notes)
|
|
||||||
* [Dependencies](#dependencies)
|
|
||||||
* [Acknowledgements](#acknowledgements)
|
|
||||||
|
|
||||||
## What is osxphotos?
|
## What is osxphotos?
|
||||||
|
|
||||||
@@ -150,13 +98,13 @@ import osxphotos
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
photosdb = osxphotos.PhotosDB()
|
photosdb = osxphotos.PhotosDB()
|
||||||
print(photosdb.keywords())
|
print(photosdb.keywords)
|
||||||
print(photosdb.persons())
|
print(photosdb.persons)
|
||||||
print(photosdb.albums())
|
print(photosdb.albums)
|
||||||
|
|
||||||
print(photosdb.keywords_as_dict())
|
print(photosdb.keywords_as_dict)
|
||||||
print(photosdb.persons_as_dict())
|
print(photosdb.persons_as_dict)
|
||||||
print(photosdb.albums_as_dict())
|
print(photosdb.albums_as_dict)
|
||||||
|
|
||||||
# find all photos with Keyword = Foo and containing John Smith
|
# find all photos with Keyword = Foo and containing John Smith
|
||||||
photos = photosdb.photos(keywords=["Foo"],persons=["John Smith"])
|
photos = photosdb.photos(keywords=["Foo"],persons=["John Smith"])
|
||||||
@@ -278,78 +226,78 @@ Pass the fully qualified path to the Photos library or the actual database file
|
|||||||
|
|
||||||
Returns a PhotosDB object.
|
Returns a PhotosDB object.
|
||||||
|
|
||||||
#### ```keywords()```
|
#### ```keywords```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
keywords = photosdb.keywords()
|
keywords = photosdb.keywords
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a list of the keywords found in the Photos library
|
Returns a list of the keywords found in the Photos library
|
||||||
|
|
||||||
#### ```albums()```
|
#### ```albums```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
albums = photosdb.albums()
|
albums = photosdb.albums
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a list of the albums found in the Photos library.
|
Returns a list of the albums found in the Photos library.
|
||||||
|
|
||||||
**Note**: In Photos 5.0 (MacOS 10.15/Catalina), It is possible to have more than one album with the same name in Photos. Albums with duplicate names are treated as a single album and the photos in each are combined. For example, if you have two albums named "Wedding" and each has 2 photos, osxphotos will treat this as a single album named "Wedding" with 4 photos in it.
|
**Note**: In Photos 5.0 (MacOS 10.15/Catalina), It is possible to have more than one album with the same name in Photos. Albums with duplicate names are treated as a single album and the photos in each are combined. For example, if you have two albums named "Wedding" and each has 2 photos, osxphotos will treat this as a single album named "Wedding" with 4 photos in it.
|
||||||
|
|
||||||
#### ```persons()```
|
#### ```persons```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
persons = photosdb.persons()
|
persons = photosdb.persons
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a list of the persons (faces) found in the Photos library
|
Returns a list of the persons (faces) found in the Photos library
|
||||||
|
|
||||||
#### ```keywords_as_dict()```
|
#### ```keywords_as_dict```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
keyword_dict = photosdb.keywords_as_dict()
|
keyword_dict = photosdb.keywords_as_dict
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a dictionary of keywords found in the Photos library where key is the keyword and value is the count of how many times that keyword appears in the library (ie. how many photos are tagged with the keyword). Resulting dictionary is in reverse sorted order (e.g. keyword with the highest count is first).
|
Returns a dictionary of keywords found in the Photos library where key is the keyword and value is the count of how many times that keyword appears in the library (ie. how many photos are tagged with the keyword). Resulting dictionary is in reverse sorted order (e.g. keyword with the highest count is first).
|
||||||
|
|
||||||
#### ```persons_as_dict()```
|
#### ```persons_as_dict```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
persons_dict = photosdb.persons_as_dict()
|
persons_dict = photosdb.persons_as_dict
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a dictionary of persons (faces) found in the Photos library where key is the person name and value is the count of how many times that person appears in the library (ie. how many photos are tagged with the person). Resulting dictionary is in reverse sorted order (e.g. person who appears in the most photos is listed first).
|
Returns a dictionary of persons (faces) found in the Photos library where key is the person name and value is the count of how many times that person appears in the library (ie. how many photos are tagged with the person). Resulting dictionary is in reverse sorted order (e.g. person who appears in the most photos is listed first).
|
||||||
|
|
||||||
#### ```albums_as_dict()```
|
#### ```albums_as_dict```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
albums_dict = photosdb.albums_as_dict()
|
albums_dict = photosdb.albums_as_dict
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a dictionary of albums found in the Photos library where key is the album name and value is the count of how many photos are in the album. Resulting dictionary is in reverse sorted order (e.g. album with the most photos is listed first).
|
Returns a dictionary of albums found in the Photos library where key is the album name and value is the count of how many photos are in the album. Resulting dictionary is in reverse sorted order (e.g. album with the most photos is listed first).
|
||||||
|
|
||||||
**Note**: In Photos 5.0 (MacOS 10.15/Catalina), It is possible to have more than one album with the same name in Photos. Albums with duplicate names are treated as a single album and the photos in each are combined. For example, if you have two albums named "Wedding" and each has 2 photos, osxphotos will treat this as a single album named "Wedding" with 4 photos in it.
|
**Note**: In Photos 5.0 (MacOS 10.15/Catalina), It is possible to have more than one album with the same name in Photos. Albums with duplicate names are treated as a single album and the photos in each are combined. For example, if you have two albums named "Wedding" and each has 2 photos, osxphotos will treat this as a single album named "Wedding" with 4 photos in it.
|
||||||
|
|
||||||
#### ```get_library_path()```
|
#### ```library_path```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
photosdb.get_photos_library_path()
|
photosdb.library_path
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns the path to the Photos library as a string
|
Returns the path to the Photos library as a string
|
||||||
|
|
||||||
#### ```get_db_path()```
|
#### ```db_path```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
photosdb.get_db_path()
|
photosdb.db_path
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns the path to the Photos database PhotosDB was initialized with
|
Returns the path to the Photos database PhotosDB was initialized with
|
||||||
|
|
||||||
#### ```get_db_version()```
|
#### ```db_version```
|
||||||
```python
|
```python
|
||||||
# assumes photosdb is a PhotosDB object (see above)
|
# assumes photosdb is a PhotosDB object (see above)
|
||||||
photosdb.get_db_version()
|
photosdb.db_version
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns the version number for Photos library database. You likely won't need this but it's provided in case needed for debugging. PhotosDB will print a warning to `sys.stderr` if you open a database version that has not been tested.
|
Returns the version number for Photos library database. You likely won't need this but it's provided in case needed for debugging. PhotosDB will print a warning to `sys.stderr` if you open a database version that has not been tested.
|
||||||
@@ -425,55 +373,55 @@ photos3 = [p for p in photos2 if p not in photos1]
|
|||||||
### PhotoInfo
|
### PhotoInfo
|
||||||
PhotosDB.photos() returns a list of PhotoInfo objects. Each PhotoInfo object represents a single photo in the Photos library.
|
PhotosDB.photos() returns a list of PhotoInfo objects. Each PhotoInfo object represents a single photo in the Photos library.
|
||||||
|
|
||||||
#### `uuid()`
|
#### `uuid`
|
||||||
Returns the universally unique identifier (uuid) of the photo. This is how Photos keeps track of individual photos within the database.
|
Returns the universally unique identifier (uuid) of the photo. This is how Photos keeps track of individual photos within the database.
|
||||||
|
|
||||||
#### `filename()`
|
#### `filename`
|
||||||
Returns the current filename of the photo on disk. See also `original_filename()`
|
Returns the current filename of the photo on disk. See also `original_filename`
|
||||||
|
|
||||||
#### `original_filename()`
|
#### `original_filename`
|
||||||
Returns the original filename of the photo when it was imported to Photos. **Note**: Photos 5.0+ renames the photo when it adds the file to the library using UUID. See also `filename()`
|
Returns the original filename of the photo when it was imported to Photos. **Note**: Photos 5.0+ renames the photo when it adds the file to the library using UUID. See also `filename`
|
||||||
|
|
||||||
#### `date()`
|
#### `date`
|
||||||
Returns the date of the photo as a datetime.datetime object
|
Returns the date of the photo as a datetime.datetime object
|
||||||
|
|
||||||
#### `description()`
|
#### `description`
|
||||||
Returns the description of the photo
|
Returns the description of the photo
|
||||||
|
|
||||||
#### `title()`
|
#### `title`
|
||||||
Returns the title of the photo
|
Returns the title of the photo
|
||||||
|
|
||||||
#### `keywords()`
|
#### `keywords`
|
||||||
Returns a list of keywords (e.g. tags) applied to the photo
|
Returns a list of keywords (e.g. tags) applied to the photo
|
||||||
|
|
||||||
#### `albums()`
|
#### `albums`
|
||||||
Returns a list of albums the photo is contained in
|
Returns a list of albums the photo is contained in
|
||||||
|
|
||||||
#### `persons()`
|
#### `persons`
|
||||||
Returns a list of the names of the persons in the photo
|
Returns a list of the names of the persons in the photo
|
||||||
|
|
||||||
#### `path()`
|
#### `path`
|
||||||
Returns the absolute path to the photo on disk as a string. **Note**: this returns the path to the *original* unedited file (see `hasadjustments()`). If the file is missing on disk, path=`None` (see `ismissing()`)
|
Returns the absolute path to the photo on disk as a string. **Note**: this returns the path to the *original* unedited file (see `hasadjustments`). If the file is missing on disk, path=`None` (see `ismissing`)
|
||||||
|
|
||||||
#### `path_edited()`
|
#### `path_edited`
|
||||||
Returns the absolute path to the edited photo on disk as a string. If the photo has not been edited, returns `None`. See also `path()` and `hasadjustments()`.
|
Returns the absolute path to the edited photo on disk as a string. If the photo has not been edited, returns `None`. See also `path` and `hasadjustments`.
|
||||||
|
|
||||||
#### `ismissing()`
|
#### `ismissing`
|
||||||
Returns `True` if the original image file is missing on disk, otherwise `False`. This can occur if the file has been uploaded to iCloud but not yet downloaded to the local library or if the file was deleted or imported from a disk that has been unmounted. **Note**: this status is set by Photos and osxphotos does not verify that the file path returned by `path()` actually exists. It merely reports what Photos has stored in the library database.
|
Returns `True` if the original image file is missing on disk, otherwise `False`. This can occur if the file has been uploaded to iCloud but not yet downloaded to the local library or if the file was deleted or imported from a disk that has been unmounted. **Note**: this status is set by Photos and osxphotos does not verify that the file path returned by `path` actually exists. It merely reports what Photos has stored in the library database.
|
||||||
|
|
||||||
#### `hasadjustments()`
|
#### `hasadjustments`
|
||||||
Returns `True` if the picture has been edited, otherwise `False`
|
Returns `True` if the picture has been edited, otherwise `False`
|
||||||
|
|
||||||
#### `external_edit()`
|
#### `external_edit`
|
||||||
Returns `True` if the picture was edited in an external editor (outside Photos.app), otherwise `False`
|
Returns `True` if the picture was edited in an external editor (outside Photos.app), otherwise `False`
|
||||||
|
|
||||||
#### `favorite()`
|
#### `favorite`
|
||||||
Returns `True` if the picture has been marked as a favorite, otherwise `False`
|
Returns `True` if the picture has been marked as a favorite, otherwise `False`
|
||||||
|
|
||||||
#### `hidden()`
|
#### `hidden`
|
||||||
Returns `True` if the picture has been marked as hidden, otherwise `False`
|
Returns `True` if the picture has been marked as hidden, otherwise `False`
|
||||||
|
|
||||||
#### `location()`
|
#### `location`
|
||||||
Returns latitude and longitude as a tuple of floats (latitude, longitude). If location is not set, latitude and longitude are returned as `None`
|
Returns latitude and longitude as a tuple of floats (latitude, longitude). If location is not set, latitude and longitude are returned as `None`
|
||||||
|
|
||||||
#### `json()`
|
#### `json()`
|
||||||
@@ -522,43 +470,69 @@ This is the same format used by exiftool's json format.
|
|||||||
```python
|
```python
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB()
|
def main():
|
||||||
photos=photosdb.photos()
|
photosdb = osxphotos.PhotosDB()
|
||||||
|
print(f"db file = {photosdb.db_path}")
|
||||||
|
print(f"db version = {photosdb.db_version}")
|
||||||
|
|
||||||
for p in photos:
|
print(photosdb.keywords)
|
||||||
|
print(photosdb.persons)
|
||||||
|
print(photosdb.albums)
|
||||||
|
|
||||||
|
print(photosdb.keywords_as_dict)
|
||||||
|
print(photosdb.persons_as_dict)
|
||||||
|
print(photosdb.albums_as_dict)
|
||||||
|
|
||||||
|
# find all photos with Keyword = Kids and containing person Katie
|
||||||
|
photos = photosdb.photos(keywords=["Kids"], persons=["Katie"])
|
||||||
|
print(f"found {len(photos)} photos")
|
||||||
|
|
||||||
|
# find all photos that include Katie but do not contain the keyword wedding
|
||||||
|
photos = [
|
||||||
|
p
|
||||||
|
for p in photosdb.photos(persons=["Katie"])
|
||||||
|
if p not in photosdb.photos(keywords=["wedding"])
|
||||||
|
]
|
||||||
|
|
||||||
|
# get all photos in the database
|
||||||
|
photos = photosdb.photos()
|
||||||
|
for p in photos:
|
||||||
print(
|
print(
|
||||||
p.uuid(),
|
p.uuid,
|
||||||
p.filename(),
|
p.filename,
|
||||||
p.original_filename(),
|
p.date,
|
||||||
p.date(),
|
p.description,
|
||||||
p.description(),
|
p.title,
|
||||||
p.name(),
|
p.keywords,
|
||||||
p.keywords(),
|
p.albums,
|
||||||
p.albums(),
|
p.persons,
|
||||||
p.persons(),
|
p.path,
|
||||||
p.path(),
|
p.ismissing,
|
||||||
p.ismissing(),
|
p.hasadjustments,
|
||||||
p.hasadjustments(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
```
|
```
|
||||||
|
|
||||||
## History
|
## Related Projects
|
||||||
|
|
||||||
This project started as a command line utility, `photosmeta`, available at [photosmeta](https://github.com/RhetTbull/photosmeta) This module converts the photosmeta Photos library query functionality into a module.
|
[photosmeta](https://github.com/rhettbull/photosmeta): uses osxphotos and [exiftool](https://exiftool.org/) to apply metadata from Photos as exif data in the photo files.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributing is easy! If you find bugs or want to suggest additional features/changes, please open an [issue](https://github.com/RhetTbull/osxphotos/issues/).
|
Contributing is easy! if you find bugs or want to suggest additional features/changes, please open an [issue](https://github.com/rhettbull/osxphotos/issues/).
|
||||||
|
|
||||||
I'll gladly consider pull requests for bug fixes or feature implementations.
|
I'll gladly consider pull requests for bug fixes or feature implementations.
|
||||||
|
|
||||||
If you have an interesting example that shows usage of this module, submit an issue or pull request and I'll include it or link to it.
|
If you have an interesting example that shows usage of this module, submit an issue or pull request and i'll include it or link to it.
|
||||||
|
|
||||||
## Implementation Notes
|
## Implementation Notes
|
||||||
|
|
||||||
This module works by creating a copy of the sqlite3 database that Photos uses to store data about the Photos library. The class PhotosDB then queries this database to extract information about the photos such as persons (faces identified in the photos), albums, keywords, etc.
|
This module works by creating a copy of the sqlite3 database that photos uses to store data about the photos library. the class photosdb then queries this database to extract information about the photos such as persons (faces identified in the photos), albums, keywords, etc.
|
||||||
|
|
||||||
If Apple changes the database format this will likely break.
|
If apple changes the database format this will likely break.
|
||||||
|
|
||||||
Apple does provide a framework ([PhotoKit](https://developer.apple.com/documentation/photokit?language=objc)) for querying the user's Photos library and I attempted to create the funcationality in this module using this framework but unfortunately PhotoKit does not provide access to much of the needed metadata (such as Faces/Persons). While copying the sqlite file is a bit kludgy, it allows osxphotos to provide access to all available metadata.
|
Apple does provide a framework ([PhotoKit](https://developer.apple.com/documentation/photokit?language=objc)) for querying the user's Photos library and I attempted to create the funcationality in this module using this framework but unfortunately PhotoKit does not provide access to much of the needed metadata (such as Faces/Persons). While copying the sqlite file is a bit kludgy, it allows osxphotos to provide access to all available metadata.
|
||||||
|
|
||||||
@@ -570,7 +544,3 @@ Apple does provide a framework ([PhotoKit](https://developer.apple.com/documenta
|
|||||||
## Acknowledgements
|
## Acknowledgements
|
||||||
This project was originally inspired by photo-export by Patrick Fältström see: (https://github.com/patrikhson/photo-export) Copyright (c) 2015 Patrik Fältström paf@frobbit.se
|
This project was originally inspired by photo-export by Patrick Fältström see: (https://github.com/patrikhson/photo-export) Copyright (c) 2015 Patrik Fältström paf@frobbit.se
|
||||||
|
|
||||||
To interact with the Photos app, I use [py-applescript]( https://github.com/rdhyee/py-applescript) by "Raymond Yee / rdhyee". Rather than import this module, I included the entire module
|
|
||||||
(which is published as public domain code) in a private module to prevent ambiguity with
|
|
||||||
other applescript modules on PyPi. py-applescript uses a native bridge via PyObjC and
|
|
||||||
is very fast compared to the other osascript based modules.
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ import osxphotos
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
photosdb = osxphotos.PhotosDB()
|
photosdb = osxphotos.PhotosDB()
|
||||||
print(f"db file = {photosdb.get_db_path()}")
|
print(f"db file = {photosdb.db_path}")
|
||||||
print(f"db version = {photosdb.get_db_version()}")
|
print(f"db version = {photosdb.db_version}")
|
||||||
|
|
||||||
print(photosdb.keywords())
|
print(photosdb.keywords)
|
||||||
print(photosdb.persons())
|
print(photosdb.persons)
|
||||||
print(photosdb.albums())
|
print(photosdb.albums)
|
||||||
|
|
||||||
print(photosdb.keywords_as_dict())
|
print(photosdb.keywords_as_dict)
|
||||||
print(photosdb.persons_as_dict())
|
print(photosdb.persons_as_dict)
|
||||||
print(photosdb.albums_as_dict())
|
print(photosdb.albums_as_dict)
|
||||||
|
|
||||||
# find all photos with Keyword = Kids and containing person Katie
|
# find all photos with Keyword = Kids and containing person Katie
|
||||||
photos = photosdb.photos(keywords=["Kids"], persons=["Katie"])
|
photos = photosdb.photos(keywords=["Kids"], persons=["Katie"])
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ def cli(ctx, db, json, debug):
|
|||||||
def keywords(cli_obj):
|
def keywords(cli_obj):
|
||||||
""" Print out keywords found in the Photos library. """
|
""" Print out keywords found in the Photos library. """
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=cli_obj.db)
|
photosdb = osxphotos.PhotosDB(dbfile=cli_obj.db)
|
||||||
keywords = {"keywords": photosdb.keywords_as_dict()}
|
keywords = {"keywords": photosdb.keywords_as_dict}
|
||||||
if cli_obj.json:
|
if cli_obj.json:
|
||||||
click.echo(json.dumps(keywords))
|
click.echo(json.dumps(keywords))
|
||||||
else:
|
else:
|
||||||
@@ -62,7 +62,7 @@ def keywords(cli_obj):
|
|||||||
def albums(cli_obj):
|
def albums(cli_obj):
|
||||||
""" Print out albums found in the Photos library. """
|
""" Print out albums found in the Photos library. """
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=cli_obj.db)
|
photosdb = osxphotos.PhotosDB(dbfile=cli_obj.db)
|
||||||
albums = {"albums": photosdb.albums_as_dict()}
|
albums = {"albums": photosdb.albums_as_dict}
|
||||||
if cli_obj.json:
|
if cli_obj.json:
|
||||||
click.echo(json.dumps(albums))
|
click.echo(json.dumps(albums))
|
||||||
else:
|
else:
|
||||||
@@ -74,7 +74,7 @@ def albums(cli_obj):
|
|||||||
def persons(cli_obj):
|
def persons(cli_obj):
|
||||||
""" Print out persons (faces) found in the Photos library. """
|
""" Print out persons (faces) found in the Photos library. """
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=cli_obj.db)
|
photosdb = osxphotos.PhotosDB(dbfile=cli_obj.db)
|
||||||
persons = {"persons": photosdb.persons_as_dict()}
|
persons = {"persons": photosdb.persons_as_dict}
|
||||||
if cli_obj.json:
|
if cli_obj.json:
|
||||||
click.echo(json.dumps(persons))
|
click.echo(json.dumps(persons))
|
||||||
else:
|
else:
|
||||||
@@ -88,20 +88,20 @@ def info(cli_obj):
|
|||||||
pdb = osxphotos.PhotosDB(dbfile=cli_obj.db)
|
pdb = osxphotos.PhotosDB(dbfile=cli_obj.db)
|
||||||
info = {}
|
info = {}
|
||||||
info["database_path"] = pdb.get_db_path()
|
info["database_path"] = pdb.get_db_path()
|
||||||
info["database_version"] = pdb.get_db_version()
|
info["database_version"] = pdb.db_version
|
||||||
|
|
||||||
photos = pdb.photos()
|
photos = pdb.photos()
|
||||||
info["photo_count"] = len(photos)
|
info["photo_count"] = len(photos)
|
||||||
|
|
||||||
keywords = pdb.keywords_as_dict()
|
keywords = pdb.keywords_as_dict
|
||||||
info["keywords_count"] = len(keywords)
|
info["keywords_count"] = len(keywords)
|
||||||
info["keywords"] = keywords
|
info["keywords"] = keywords
|
||||||
|
|
||||||
albums = pdb.albums_as_dict()
|
albums = pdb.albums_as_dict
|
||||||
info["albums_count"] = len(albums)
|
info["albums_count"] = len(albums)
|
||||||
info["albums"] = albums
|
info["albums"] = albums
|
||||||
|
|
||||||
persons = pdb.persons_as_dict()
|
persons = pdb.persons_as_dict
|
||||||
|
|
||||||
# handle empty person names (added by Photos 5.0+ when face detected but not identified)
|
# handle empty person names (added by Photos 5.0+ when face detected but not identified)
|
||||||
# TODO: remove this
|
# TODO: remove this
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ class PhotosDB:
|
|||||||
def __del__(self):
|
def __del__(self):
|
||||||
self._cleanup_tmp_files()
|
self._cleanup_tmp_files()
|
||||||
|
|
||||||
|
@property
|
||||||
def keywords_as_dict(self):
|
def keywords_as_dict(self):
|
||||||
""" return keywords as dict of keyword, count in reverse sorted order (descending) """
|
""" return keywords as dict of keyword, count in reverse sorted order (descending) """
|
||||||
keywords = {}
|
keywords = {}
|
||||||
@@ -187,6 +188,7 @@ class PhotosDB:
|
|||||||
keywords = dict(sorted(keywords.items(), key=lambda kv: kv[1], reverse=True))
|
keywords = dict(sorted(keywords.items(), key=lambda kv: kv[1], reverse=True))
|
||||||
return keywords
|
return keywords
|
||||||
|
|
||||||
|
@property
|
||||||
def persons_as_dict(self):
|
def persons_as_dict(self):
|
||||||
""" return persons as dict of person, count in reverse sorted order (descending) """
|
""" return persons as dict of person, count in reverse sorted order (descending) """
|
||||||
persons = {}
|
persons = {}
|
||||||
@@ -195,6 +197,7 @@ class PhotosDB:
|
|||||||
persons = dict(sorted(persons.items(), key=lambda kv: kv[1], reverse=True))
|
persons = dict(sorted(persons.items(), key=lambda kv: kv[1], reverse=True))
|
||||||
return persons
|
return persons
|
||||||
|
|
||||||
|
@property
|
||||||
def albums_as_dict(self):
|
def albums_as_dict(self):
|
||||||
""" return albums as dict of albums, count in reverse sorted order (descending) """
|
""" return albums as dict of albums, count in reverse sorted order (descending) """
|
||||||
albums = {}
|
albums = {}
|
||||||
@@ -207,16 +210,19 @@ class PhotosDB:
|
|||||||
albums = dict(sorted(albums.items(), key=lambda kv: kv[1], reverse=True))
|
albums = dict(sorted(albums.items(), key=lambda kv: kv[1], reverse=True))
|
||||||
return albums
|
return albums
|
||||||
|
|
||||||
|
@property
|
||||||
def keywords(self):
|
def keywords(self):
|
||||||
""" return list of keywords found in photos database """
|
""" return list of keywords found in photos database """
|
||||||
keywords = self._dbkeywords_keyword.keys()
|
keywords = self._dbkeywords_keyword.keys()
|
||||||
return list(keywords)
|
return list(keywords)
|
||||||
|
|
||||||
|
@property
|
||||||
def persons(self):
|
def persons(self):
|
||||||
""" return list of persons found in photos database """
|
""" return list of persons found in photos database """
|
||||||
persons = self._dbfaces_person.keys()
|
persons = self._dbfaces_person.keys()
|
||||||
return list(persons)
|
return list(persons)
|
||||||
|
|
||||||
|
@property
|
||||||
def albums(self):
|
def albums(self):
|
||||||
""" return list of albums found in photos database """
|
""" return list of albums found in photos database """
|
||||||
# Could be more than one album with same name
|
# Could be more than one album with same name
|
||||||
@@ -266,15 +272,18 @@ class PhotosDB:
|
|||||||
# """
|
# """
|
||||||
# )
|
# )
|
||||||
|
|
||||||
def get_db_version(self):
|
@property
|
||||||
|
def db_version(self):
|
||||||
""" return the database version as stored in LiGlobals table """
|
""" return the database version as stored in LiGlobals table """
|
||||||
return self._db_version
|
return self._db_version
|
||||||
|
|
||||||
def get_db_path(self):
|
@property
|
||||||
|
def db_path(self):
|
||||||
""" returns path to the Photos library database PhotosDB was initialized with """
|
""" returns path to the Photos library database PhotosDB was initialized with """
|
||||||
return os.path.abspath(self._dbfile)
|
return os.path.abspath(self._dbfile)
|
||||||
|
|
||||||
def get_library_path(self):
|
@property
|
||||||
|
def library_path(self):
|
||||||
""" returns path to the Photos library PhotosDB was initialized with """
|
""" returns path to the Photos library PhotosDB was initialized with """
|
||||||
return self._library_path
|
return self._library_path
|
||||||
|
|
||||||
@@ -1070,4 +1079,4 @@ class PhotosDB:
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
# TODO: update to use __class__ and __name__
|
# TODO: update to use __class__ and __name__
|
||||||
return f"osxphotos.PhotosDB(dbfile='{self.get_db_path()}')"
|
return f"osxphotos.PhotosDB(dbfile='{self.db_path}')"
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ def test_db_version():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
# assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS
|
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
|
||||||
assert photosdb.get_db_version() == "2622"
|
assert photosdb.db_version == "2622"
|
||||||
|
|
||||||
|
|
||||||
def test_os_version():
|
def test_os_version():
|
||||||
@@ -59,8 +59,8 @@ def test_persons():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Katie" in photosdb.persons()
|
assert "Katie" in photosdb.persons
|
||||||
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons())
|
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords():
|
def test_keywords():
|
||||||
@@ -68,8 +68,8 @@ def test_keywords():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "wedding" in photosdb.keywords()
|
assert "wedding" in photosdb.keywords
|
||||||
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords())
|
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords)
|
||||||
|
|
||||||
|
|
||||||
def test_albums():
|
def test_albums():
|
||||||
@@ -77,15 +77,15 @@ def test_albums():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Pumpkin Farm" in photosdb.albums()
|
assert "Pumpkin Farm" in photosdb.albums
|
||||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums())
|
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords_dict():
|
def test_keywords_dict():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
keywords = photosdb.keywords_as_dict()
|
keywords = photosdb.keywords_as_dict
|
||||||
assert keywords["wedding"] == 2
|
assert keywords["wedding"] == 2
|
||||||
assert keywords == KEYWORDS_DICT
|
assert keywords == KEYWORDS_DICT
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ def test_persons_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
persons = photosdb.persons_as_dict()
|
persons = photosdb.persons_as_dict
|
||||||
assert persons["Maria"] == 1
|
assert persons["Maria"] == 1
|
||||||
assert persons == PERSONS_DICT
|
assert persons == PERSONS_DICT
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ def test_albums_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
albums = photosdb.albums_as_dict()
|
albums = photosdb.albums_as_dict
|
||||||
assert albums["Pumpkin Farm"] == 3
|
assert albums["Pumpkin Farm"] == 3
|
||||||
assert albums == ALBUM_DICT
|
assert albums == ALBUM_DICT
|
||||||
|
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ def test_db_version():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
# assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS
|
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
|
||||||
assert photosdb.get_db_version() == "6000"
|
assert photosdb.db_version == "6000"
|
||||||
|
|
||||||
|
|
||||||
def test_os_version():
|
def test_os_version():
|
||||||
@@ -136,8 +136,8 @@ def test_persons():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Katie" in photosdb.persons()
|
assert "Katie" in photosdb.persons
|
||||||
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons())
|
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords():
|
def test_keywords():
|
||||||
@@ -145,8 +145,8 @@ def test_keywords():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "wedding" in photosdb.keywords()
|
assert "wedding" in photosdb.keywords
|
||||||
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords())
|
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords)
|
||||||
|
|
||||||
|
|
||||||
def test_albums():
|
def test_albums():
|
||||||
@@ -154,15 +154,15 @@ def test_albums():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Pumpkin Farm" in photosdb.albums()
|
assert "Pumpkin Farm" in photosdb.albums
|
||||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums())
|
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords_dict():
|
def test_keywords_dict():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
keywords = photosdb.keywords_as_dict()
|
keywords = photosdb.keywords_as_dict
|
||||||
assert keywords["wedding"] == 2
|
assert keywords["wedding"] == 2
|
||||||
assert keywords == KEYWORDS_DICT
|
assert keywords == KEYWORDS_DICT
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ def test_persons_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
persons = photosdb.persons_as_dict()
|
persons = photosdb.persons_as_dict
|
||||||
assert persons["Maria"] == 1
|
assert persons["Maria"] == 1
|
||||||
assert persons == PERSONS_DICT
|
assert persons == PERSONS_DICT
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ def test_albums_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
albums = photosdb.albums_as_dict()
|
albums = photosdb.albums_as_dict
|
||||||
assert albums["Pumpkin Farm"] == 3
|
assert albums["Pumpkin Farm"] == 3
|
||||||
assert albums == ALBUM_DICT
|
assert albums == ALBUM_DICT
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ def test_get_db_path():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
db_path = photosdb.get_db_path()
|
db_path = photosdb.db_path
|
||||||
assert db_path.endswith(PHOTOS_DB_PATH)
|
assert db_path.endswith(PHOTOS_DB_PATH)
|
||||||
|
|
||||||
|
|
||||||
@@ -399,7 +399,7 @@ def test_get_library_path():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
lib_path = photosdb.get_library_path()
|
lib_path = photosdb.library_path
|
||||||
assert lib_path.endswith(PHOTOS_LIBRARY_PATH)
|
assert lib_path.endswith(PHOTOS_LIBRARY_PATH)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ def test_db_version():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert photosdb.get_db_version() == "3301"
|
assert photosdb.db_version == "3301"
|
||||||
# assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS
|
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
|
||||||
|
|
||||||
|
|
||||||
def test_os_version():
|
def test_os_version():
|
||||||
@@ -58,8 +58,8 @@ def test_persons():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Katie" in photosdb.persons()
|
assert "Katie" in photosdb.persons
|
||||||
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons())
|
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords():
|
def test_keywords():
|
||||||
@@ -67,8 +67,8 @@ def test_keywords():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "wedding" in photosdb.keywords()
|
assert "wedding" in photosdb.keywords
|
||||||
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords())
|
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords)
|
||||||
|
|
||||||
|
|
||||||
def test_albums():
|
def test_albums():
|
||||||
@@ -76,15 +76,15 @@ def test_albums():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Pumpkin Farm" in photosdb.albums()
|
assert "Pumpkin Farm" in photosdb.albums
|
||||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums())
|
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords_dict():
|
def test_keywords_dict():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
keywords = photosdb.keywords_as_dict()
|
keywords = photosdb.keywords_as_dict
|
||||||
assert keywords["wedding"] == 2
|
assert keywords["wedding"] == 2
|
||||||
assert keywords == KEYWORDS_DICT
|
assert keywords == KEYWORDS_DICT
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ def test_persons_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
persons = photosdb.persons_as_dict()
|
persons = photosdb.persons_as_dict
|
||||||
assert persons["Maria"] == 1
|
assert persons["Maria"] == 1
|
||||||
assert persons == PERSONS_DICT
|
assert persons == PERSONS_DICT
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ def test_albums_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
albums = photosdb.albums_as_dict()
|
albums = photosdb.albums_as_dict
|
||||||
assert albums["Pumpkin Farm"] == 3
|
assert albums["Pumpkin Farm"] == 3
|
||||||
assert albums == ALBUM_DICT
|
assert albums == ALBUM_DICT
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ def test_db_version():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
# assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS
|
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
|
||||||
assert photosdb.get_db_version() == "4016"
|
assert photosdb.db_version == "4016"
|
||||||
|
|
||||||
|
|
||||||
def test_os_version():
|
def test_os_version():
|
||||||
@@ -58,8 +58,8 @@ def test_persons():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Katie" in photosdb.persons()
|
assert "Katie" in photosdb.persons
|
||||||
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons())
|
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords():
|
def test_keywords():
|
||||||
@@ -67,8 +67,8 @@ def test_keywords():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "wedding" in photosdb.keywords()
|
assert "wedding" in photosdb.keywords
|
||||||
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords())
|
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords)
|
||||||
|
|
||||||
|
|
||||||
def test_albums():
|
def test_albums():
|
||||||
@@ -76,15 +76,15 @@ def test_albums():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Pumpkin Farm" in photosdb.albums()
|
assert "Pumpkin Farm" in photosdb.albums
|
||||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums())
|
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords_dict():
|
def test_keywords_dict():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
keywords = photosdb.keywords_as_dict()
|
keywords = photosdb.keywords_as_dict
|
||||||
assert keywords["wedding"] == 2
|
assert keywords["wedding"] == 2
|
||||||
assert keywords == KEYWORDS_DICT
|
assert keywords == KEYWORDS_DICT
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ def test_persons_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
persons = photosdb.persons_as_dict()
|
persons = photosdb.persons_as_dict
|
||||||
assert persons["Maria"] == 1
|
assert persons["Maria"] == 1
|
||||||
assert persons == PERSONS_DICT
|
assert persons == PERSONS_DICT
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ def test_albums_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
albums = photosdb.albums_as_dict()
|
albums = photosdb.albums_as_dict
|
||||||
assert albums["Pumpkin Farm"] == 3
|
assert albums["Pumpkin Farm"] == 3
|
||||||
assert albums == ALBUM_DICT
|
assert albums == ALBUM_DICT
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ def test_db_version():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert photosdb.get_db_version() in osxphotos._constants._TESTED_DB_VERSIONS
|
assert photosdb.db_version in osxphotos._constants._TESTED_DB_VERSIONS
|
||||||
assert photosdb.get_db_version() == "4025"
|
assert photosdb.db_version == "4025"
|
||||||
|
|
||||||
|
|
||||||
def test_os_version():
|
def test_os_version():
|
||||||
@@ -61,8 +61,8 @@ def test_persons():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Katie" in photosdb.persons()
|
assert "Katie" in photosdb.persons
|
||||||
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons())
|
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords():
|
def test_keywords():
|
||||||
@@ -70,8 +70,8 @@ def test_keywords():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "wedding" in photosdb.keywords()
|
assert "wedding" in photosdb.keywords
|
||||||
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords())
|
assert collections.Counter(KEYWORDS) == collections.Counter(photosdb.keywords)
|
||||||
|
|
||||||
|
|
||||||
def test_albums():
|
def test_albums():
|
||||||
@@ -79,15 +79,15 @@ def test_albums():
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "Pumpkin Farm" in photosdb.albums()
|
assert "Pumpkin Farm" in photosdb.albums
|
||||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums())
|
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords_dict():
|
def test_keywords_dict():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
keywords = photosdb.keywords_as_dict()
|
keywords = photosdb.keywords_as_dict
|
||||||
assert keywords["wedding"] == 2
|
assert keywords["wedding"] == 2
|
||||||
assert keywords == KEYWORDS_DICT
|
assert keywords == KEYWORDS_DICT
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ def test_persons_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
persons = photosdb.persons_as_dict()
|
persons = photosdb.persons_as_dict
|
||||||
assert persons["Maria"] == 1
|
assert persons["Maria"] == 1
|
||||||
assert persons == PERSONS_DICT
|
assert persons == PERSONS_DICT
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ def test_albums_as_dict():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
albums = photosdb.albums_as_dict()
|
albums = photosdb.albums_as_dict
|
||||||
assert albums["Pumpkin Farm"] == 3
|
assert albums["Pumpkin Farm"] == 3
|
||||||
assert albums == ALBUM_DICT
|
assert albums == ALBUM_DICT
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ def test_get_db_path():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
db_path = photosdb.get_db_path()
|
db_path = photosdb.db_path
|
||||||
assert db_path.endswith(PHOTOS_DB_PATH)
|
assert db_path.endswith(PHOTOS_DB_PATH)
|
||||||
|
|
||||||
|
|
||||||
@@ -322,5 +322,5 @@ def test_get_library_path():
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
lib_path = photosdb.get_library_path()
|
lib_path = photosdb.library_path
|
||||||
assert lib_path.endswith(PHOTOS_LIBRARY_PATH)
|
assert lib_path.endswith(PHOTOS_LIBRARY_PATH)
|
||||||
|
|||||||
Reference in New Issue
Block a user