Updated README, added os & db version tests, updated test library for 10.13

This commit is contained in:
Rhet Turnbull
2019-07-27 21:45:37 -04:00
parent 32bd4cfb9d
commit a58ac149f3
28 changed files with 81 additions and 29 deletions

View File

@@ -1,4 +1,7 @@
# [OSXPhotos](https://github.com/RhetTbull/osxphotos)
# OSXPhotos [Homepage](https://github.com/RhetTbull/osxphotos)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
## What is osxphotos?

View File

@@ -21,12 +21,13 @@ from . import _applescript
# TODO: standardize _ and __ as leading char for private variables
# which Photos library database versions have been tested
# Photos 3.0 (10.13.6) ==
# Photos 3.0 (10.13.6) ==
# Photos 4.0 (10.14.5) == 4016
_TESTED_DB_VERSIONS = ["4016"]
# TODO: Should this also use compatibleBackToVersion from LiGlobals?
_TESTED_DB_VERSIONS = ["4016", "3301"]
# which major version operating systems have been tested
_TESTED_OS_VERSIONS = ["13","14"]
_TESTED_OS_VERSIONS = ["13", "14"]
_debug = False
@@ -53,9 +54,10 @@ class PhotosDB:
# logger.debug(system, major)
if system != "Darwin" or (major not in _TESTED_OS_VERSIONS):
print(
"WARNING: This module has only been tested with MacOS 10."
"WARNING: This module has only been tested with MacOS 10."
+ f"[{', '.join(_TESTED_OS_VERSIONS)}]: "
+ f"you have {system}, OS version: {major}", file=sys.stderr
+ f"you have {system}, OS version: {major}",
file=sys.stderr,
)
# Dict with information about all photos by uuid
@@ -275,14 +277,18 @@ class PhotosDB:
# logger.debug("Have connection with database")
# get database version
c.execute("SELECT value from LiGlobals where LiGlobals.keyPath is 'libraryVersion'")
c.execute(
"SELECT value from LiGlobals where LiGlobals.keyPath is 'libraryVersion'"
)
for ver in c:
self.__db_version = ver[0]
break # TODO: is there a more pythonic way to do get the first element from cursor?
if self.__db_version not in _TESTED_DB_VERSIONS:
print(f"WARNING: Only tested on database versions [{', '.join(_TESTED_DB_VERSIONS)}]"
+f" You have database version={self.__db_version} which has not been tested")
print(
f"WARNING: Only tested on database versions [{', '.join(_TESTED_DB_VERSIONS)}]"
+ f" You have database version={self.__db_version} which has not been tested"
)
# Look for all combinations of persons and pictures
# logger.debug("Getting information about persons")
@@ -434,17 +440,17 @@ class PhotosDB:
self._dbphotos[uuid]["name"] = row[13]
self._dbphotos[uuid]["isMissing"] = row[14]
# logger.debug(
# "Fetching data for photo %d %s %s %s %s %s: %s"
# % (
# i,
# uuid,
# self._dbphotos[uuid]["masterUuid"],
# self._dbphotos[uuid]["volumeId"],
# self._dbphotos[uuid]["filename"],
# self._dbphotos[uuid]["extendedDescription"],
# self._dbphotos[uuid]["imageDate"],
# )
# )
# "Fetching data for photo %d %s %s %s %s %s: %s"
# % (
# i,
# uuid,
# self._dbphotos[uuid]["masterUuid"],
# self._dbphotos[uuid]["volumeId"],
# self._dbphotos[uuid]["filename"],
# self._dbphotos[uuid]["extendedDescription"],
# self._dbphotos[uuid]["imageDate"],
# )
# )
# close_pbar_status()
conn.close()
@@ -518,7 +524,7 @@ class PhotosDB:
"""
def photos(self, keywords=[], uuid=[], persons=[], albums=[]):
#TODO: remove the logger code then dangling else: pass statements
# TODO: remove the logger code then dangling else: pass statements
photos_sets = [] # list of photo sets to perform intersection of
if not keywords and not uuid and not persons and not albums:
# return all the photos
@@ -605,6 +611,7 @@ class PhotoInfo:
downloaded from cloud to local storate their status in the database might still show
isMissing = 1
"""
def path(self):
photopath = ""
@@ -616,7 +623,7 @@ class PhotoInfo:
if self.__info["isMissing"] == 1:
# logger.warning(
# f"Skipping photo, not yet downloaded from iCloud: {photopath}"
# f"Skipping photo, not yet downloaded from iCloud: {photopath}"
# )
# logger.debug(self.__info)
photopath = None # path would be meaningless until downloaded

View File

@@ -38,7 +38,7 @@ with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
setup(
name="osxphotos",
version="0.10.2",
version="0.10.3",
description="Manipulate (read-only) Apple's Photos app library on Mac OS X",
long_description=long_description,
long_description_content_type="text/markdown",

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@@ -3,8 +3,8 @@
<plist version="1.0">
<dict>
<key>PhotoAnalysisGraphLastBackgroundGraphRebuildJobDate</key>
<date>2019-07-26T20:15:18Z</date>
<date>2019-07-28T01:23:52Z</date>
<key>PhotoAnalysisGraphLastBackgroundMemoryGenerationJobDate</key>
<date>2019-07-26T20:15:18Z</date>
<date>2019-07-28T01:23:52Z</date>
</dict>
</plist>

View File

@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>SuggestedMeIdentifier</key>
<string></string>
</dict>
</plist>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LithiumMessageTracer</key>
<dict>
<key>LastReportedDate</key>
<date>2019-07-27T12:01:15Z</date>
</dict>
</dict>
</plist>

View File

@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>LastHistoryRowId</key>
<integer>545</integer>
<integer>615</integer>
<key>LibraryBuildTag</key>
<string>BEA5F0E8-BA6B-4462-8F73-3E53BBE4C943</string>
<key>LibrarySchemaVersion</key>

View File

@@ -9,7 +9,7 @@
<key>HistoricalMarker</key>
<dict>
<key>LastHistoryRowId</key>
<integer>551</integer>
<integer>615</integer>
<key>LibraryBuildTag</key>
<string>BEA5F0E8-BA6B-4462-8F73-3E53BBE4C943</string>
<key>LibrarySchemaVersion</key>
@@ -24,7 +24,7 @@
<key>SnapshotCompletedDate</key>
<date>2019-07-26T20:15:17Z</date>
<key>SnapshotLastValidated</key>
<date>2019-07-26T20:15:17Z</date>
<date>2019-07-27T12:01:15Z</date>
<key>SnapshotTables</key>
<dict/>
</dict>

View File

@@ -38,6 +38,20 @@ def test_init():
assert isinstance(photosdb, osxphotos.PhotosDB)
def test_db_version():
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS
def test_os_version():
import osxphotos
(_, major, _) = osxphotos._get_os_version()
assert major in osxphotos._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections

View File

@@ -38,6 +38,20 @@ def test_init():
assert isinstance(photosdb, osxphotos.PhotosDB)
def test_db_version():
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS
def test_os_version():
import osxphotos
(_, major, _) = osxphotos._get_os_version()
assert major in osxphotos._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections