diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 5f7cac79..64f3c452 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -48,7 +48,7 @@ class Items(object): self.kodiconn = kodi_sql('video') self.kodicursor = self.kodiconn.cursor() self.plex_db = plexdb.Plex_DB_Functions(self.plexcursor) - self.kodi_db = kodidb.Kodidb_Functions(self.kodicursor) + self.kodi_db = kodidb.KodiDBMethods(self.kodicursor) return self def __exit__(self, exc_type, exc_val, exc_tb): @@ -1250,7 +1250,7 @@ class Music(Items): self.kodiconn = kodi_sql('music') self.kodicursor = self.kodiconn.cursor() self.plex_db = plexdb.Plex_DB_Functions(self.plexcursor) - self.kodi_db = kodidb.Kodidb_Functions(self.kodicursor) + self.kodi_db = kodidb.KodiDBMethods(self.kodicursor) return self @catch_exceptions(warnuser=True) diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index 7809b816..ee10e2ea 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -15,7 +15,7 @@ LOG = getLogger("PLEX." + __name__) ############################################################################### -class GetKodiDB(): +class GetKodiDB(object): """ Usage: with GetKodiDB(db_type) as kodi_db: do stuff with kodi_db @@ -27,19 +27,25 @@ class GetKodiDB(): and the db gets closed """ def __init__(self, db_type): + self.kodiconn = None self.db_type = db_type def __enter__(self): self.kodiconn = kodi_sql(self.db_type) - kodi_db = Kodidb_Functions(self.kodiconn.cursor()) + kodi_db = KodiDBMethods(self.kodiconn.cursor()) return kodi_db - def __exit__(self, type, value, traceback): + def __exit__(self, typus, value, traceback): self.kodiconn.commit() self.kodiconn.close() -class Kodidb_Functions(): +class KodiDBMethods(object): + """ + Best used indirectly with another Class GetKodiDB: + with GetKodiDB(db_type) as kodi_db: + kodi_db.method() + """ def __init__(self, cursor): self.cursor = cursor self.artwork = artwork.Artwork()