From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 9180B1395EA for ; Wed, 5 Aug 2015 06:02:06 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6402AE08CE; Wed, 5 Aug 2015 06:02:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0E6C714172 for ; Wed, 5 Aug 2015 06:02:02 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BA9CA34098C for ; Wed, 5 Aug 2015 06:02:01 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 08A39C3 for ; Wed, 5 Aug 2015 06:02:00 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1438754339.daafd7d31457b018797407d97188a4829839172e.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/db_modules/xml_db/, layman/db_modules/sqlite_db/, layman/, ... X-VCS-Repository: proj/layman X-VCS-Files: layman/db.py layman/db_modules/json_db/__init__.py layman/db_modules/json_db/json_db.py layman/db_modules/sqlite_db/__init__.py layman/db_modules/sqlite_db/sqlite_db.py layman/db_modules/xml_db/__init__.py layman/db_modules/xml_db/xml_db.py layman/dbbase.py X-VCS-Directories: layman/ layman/db_modules/json_db/ layman/db_modules/xml_db/ layman/db_modules/sqlite_db/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: daafd7d31457b018797407d97188a4829839172e X-VCS-Branch: master Date: Wed, 5 Aug 2015 06:02:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 860a4c91-aec8-4287-bbdf-2d24ddc5096f X-Archives-Hash: cba758d6d37e822f946f30162e60f7ed commit: daafd7d31457b018797407d97188a4829839172e Author: Devan Franchini gentoo org> AuthorDate: Wed Aug 5 05:55:16 2015 +0000 Commit: Devan Franchini gentoo org> CommitDate: Wed Aug 5 05:58:59 2015 +0000 URL: https://gitweb.gentoo.org/proj/layman.git/commit/?id=daafd7d3 Adds remove function for overlay removal from databases sqlite_db.py: Also changes the way in which feeds are gathered in read_db(), this shows the nature of feeds being an unrequired attribute of the overlay. layman/db.py | 2 +- layman/db_modules/json_db/__init__.py | 3 ++- layman/db_modules/json_db/json_db.py | 8 ++++++++ layman/db_modules/sqlite_db/__init__.py | 5 +++-- layman/db_modules/sqlite_db/sqlite_db.py | 23 ++++++++++++++++------- layman/db_modules/xml_db/__init__.py | 3 ++- layman/db_modules/xml_db/xml_db.py | 8 ++++++++ layman/dbbase.py | 13 +++++++++++++ 8 files changed, 53 insertions(+), 12 deletions(-) diff --git a/layman/db.py b/layman/db.py index ba7399c..673e6bf 100644 --- a/layman/db.py +++ b/layman/db.py @@ -148,7 +148,7 @@ class DB(DbBase): if overlay.name in self.overlays.keys(): overlay.delete(self.config['storage']) repo_ok = self.repo_conf.delete(overlay) - del self.overlays[overlay.name] + self.remove(overlay, self.path) self.write(self.path) else: self.output.error('No local overlay named "' + overlay.name + '"!') diff --git a/layman/db_modules/json_db/__init__.py b/layman/db_modules/json_db/__init__.py index 1502b9d..ac4daa7 100644 --- a/layman/db_modules/json_db/__init__.py +++ b/layman/db_modules/json_db/__init__.py @@ -13,10 +13,11 @@ module_spec = { 'name': 'json_db', 'class': 'DBHandler', 'description': __doc__, - 'functions': ['add_new', 'read_db', 'write'], + 'functions': ['add_new', 'read_db', 'remove', 'write'], 'func_desc': { 'add_new': 'Adds overlay(s) from provided database text', 'read_db': 'Reads the list of overlays from database file', + 'remove' : 'Removes overlay from installed overlays list', 'write' : 'Writes the list of overlays to database file', }, } diff --git a/layman/db_modules/json_db/json_db.py b/layman/db_modules/json_db/json_db.py index 47413c6..d466385 100644 --- a/layman/db_modules/json_db/json_db.py +++ b/layman/db_modules/json_db/json_db.py @@ -104,6 +104,14 @@ class DBHandler(object): return True + def remove(self, overlay, path): + ''' + Removes an overlay from installed overlays list. + ''' + if overlay.name in self.overlays: + del self.overlays[overlay.name] + + def write(self, path): ''' Write the list of overlays to a file. diff --git a/layman/db_modules/sqlite_db/__init__.py b/layman/db_modules/sqlite_db/__init__.py index 7d2fba4..536fc2d 100644 --- a/layman/db_modules/sqlite_db/__init__.py +++ b/layman/db_modules/sqlite_db/__init__.py @@ -13,10 +13,11 @@ module_spec = { 'name': 'sqlite_db', 'class': 'DBHandler', 'description': __doc__, - 'functions': ['add_new', 'read_db', 'write'], + 'functions': ['add_new', 'read_db', 'remove', 'write'], 'func_desc': { - 'add_new': 'Adds overlay(s) from provided database text', + 'add_new': 'Adds overlay(s) from provided database file', 'read_db': 'Reads the list of overlays from database file', + 'remove' : 'Removes overlay from provided database file', 'write' : 'Writes the list of overlays to database file', }, } diff --git a/layman/db_modules/sqlite_db/sqlite_db.py b/layman/db_modules/sqlite_db/sqlite_db.py index 1d079a3..aef9661 100644 --- a/layman/db_modules/sqlite_db/sqlite_db.py +++ b/layman/db_modules/sqlite_db/sqlite_db.py @@ -103,8 +103,8 @@ class DBHandler(object): cursor.execute('''CREATE TABLE IF NOT EXISTS Overlay ( Overlay_ID INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Priority TEXT, Status TEXT, Quality TEXT, Homepage - TEXT, IRC TEXT, License TEXT, UNIQUE (Name, Homepage, License) - ON CONFLICT IGNORE )''') + TEXT, IRC TEXT, License TEXT, UNIQUE (Name) ON CONFLICT IGNORE ) + ''') cursor.execute('''CREATE TABLE IF NOT EXISTS Owner ( Owner_ID INTEGER PRIMARY KEY AUTOINCREMENT, Owner_Name TEXT, Owner_Email TEXT, UNIQUE (Owner_Name, Owner_Email) ON @@ -180,15 +180,17 @@ class DBHandler(object): cursor.execute('''SELECT Description FROM Description JOIN Overlay USING (Overlay_ID) WHERE Overlay_ID = ?''', (overlay_id,)) - overlay['description'] = cursor.fetchall() - - if len(overlay['description']): - overlay['description'] = overlay['description'][0] + overlay['description'] = cursor.fetchall()[0] overlay['status'] = overlay_info[3] overlay['quality'] = overlay_info[4] overlay['priority'] = overlay_info[2] - overlay['license'] = overlay_info[7] + + if overlay_info[7]: + overlay['license'] = overlay_info[7] + else: + overlay['license'] = None + overlay['homepage'] = overlay_info[5] overlay['IRC'] = overlay_info[6] @@ -196,9 +198,13 @@ class DBHandler(object): (Overlay_ID) WHERE Overlay_ID = ?''', (overlay_id,)) overlay['feed'] = cursor.fetchall() + if len(overlay['feed']): + overlay['feed'] = overlay['feed'][0] + self.overlays[overlay_info[1]] = Overlay(self.config, ovl_dict=overlay, ignore=self.ignore) + connection.close() def add_new(self, document=None, origin=None): @@ -316,6 +322,9 @@ class DBHandler(object): connection.commit() + if overlay.name in self.overlays: + del self.overlays[overlay.name] + def write(self, path): ''' diff --git a/layman/db_modules/xml_db/__init__.py b/layman/db_modules/xml_db/__init__.py index 3a3abd1..c8a5bf9 100644 --- a/layman/db_modules/xml_db/__init__.py +++ b/layman/db_modules/xml_db/__init__.py @@ -13,10 +13,11 @@ module_spec = { 'name': 'xml_db', 'class': 'DBHandler', 'description': __doc__, - 'functions': ['add_new', 'read_db', 'write'], + 'functions': ['add_new', 'read_db', 'remove', 'write'], 'func_desc': { 'add_new': 'Adds overlay(s) from provided database text', 'read_db': 'Reads the list of overlays from database file', + 'remove' : 'Removes overlay from installed overlays list', 'write' : 'Writes the list of overlays to database file', }, } diff --git a/layman/db_modules/xml_db/xml_db.py b/layman/db_modules/xml_db/xml_db.py index 38a19d2..316d8f9 100644 --- a/layman/db_modules/xml_db/xml_db.py +++ b/layman/db_modules/xml_db/xml_db.py @@ -149,6 +149,14 @@ class DBHandler(object): return True + def remove(self, overlay, path): + ''' + Removes an overlay from list of installed overlays. + ''' + if overlay.name in self.overlays: + del self.overlays[overlay.name] + + def write(self, path): ''' Write the list of overlays to a file. diff --git a/layman/dbbase.py b/layman/dbbase.py index 7832565..cecbf5c 100644 --- a/layman/dbbase.py +++ b/layman/dbbase.py @@ -215,6 +215,19 @@ class DbBase(object): db_ctl.write(path) + def remove(self, overlay, path): + ''' + Remove an overlay from the database. + ''' + db_ctl = self.mod_ctl.get_class(self.db_type)(self.config, + self.overlays, + self.paths, + self.ignore, + self.ignore_init_read_errors) + + db_ctl.remove(overlay, path) + + def select(self, overlay): ''' Select an overlay from the list.