From: "Devan Franchini" <twitch153@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:master commit in: layman/db_modules/xml_db/, layman/db_modules/sqlite_db/, layman/, ...
Date: Wed, 5 Aug 2015 06:02:00 +0000 (UTC) [thread overview]
Message-ID: <1438754339.daafd7d31457b018797407d97188a4829839172e.twitch153@gentoo> (raw)
commit: daafd7d31457b018797407d97188a4829839172e
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 5 05:55:16 2015 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> 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.
next reply other threads:[~2015-08-05 6:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-05 6:02 Devan Franchini [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-02-29 6:11 [gentoo-commits] proj/layman:master commit in: layman/db_modules/xml_db/, layman/db_modules/sqlite_db/, layman/, Devan Franchini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438754339.daafd7d31457b018797407d97188a4829839172e.twitch153@gentoo \
--to=twitch153@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox