diff options
author | Devan Franchini <twitch153@gentoo.org> | 2015-07-09 12:59:57 -0400 |
---|---|---|
committer | Devan Franchini <twitch153@gentoo.org> | 2015-07-09 12:59:59 -0400 |
commit | 47349f8b5ef3012c915ff8ad7825caefde103891 (patch) | |
tree | 449850329149b96ee0fd4ec70c51d805abde872f | |
parent | dbbase.py: Adds use of db module plug-in system (diff) | |
download | layman-47349f8b5ef3012c915ff8ad7825caefde103891.tar.gz layman-47349f8b5ef3012c915ff8ad7825caefde103891.tar.bz2 layman-47349f8b5ef3012c915ff8ad7825caefde103891.zip |
dbbase.py: Modifies read_db function to allow for passing a text parameter
This was done to allow for only one read*() function and add
compatibility with the way read() was originally set up.
xml.py: read_db() is also modified in this file for the same purpose.
remotedb.py: changes the calling of self.read() to self.read_db().
-rw-r--r-- | layman/db_modules/xml/xml.py | 17 | ||||
-rw-r--r-- | layman/dbbase.py | 4 | ||||
-rw-r--r-- | layman/remotedb.py | 2 |
3 files changed, 13 insertions, 10 deletions
diff --git a/layman/db_modules/xml/xml.py b/layman/db_modules/xml/xml.py index 189e868..c444fc3 100644 --- a/layman/db_modules/xml/xml.py +++ b/layman/db_modules/xml/xml.py @@ -107,16 +107,19 @@ class DBHandler(object): raise NotImplementedError(msg) - def read_db(self, path): + def read_db(self, path, text=None): ''' Read the overlay definition file. ''' - try: - with fileopen(path, 'r') as df: - document = df.read() - except Exception as error: - if not self.ignore_init_read_errors: - msg = 'XML DBHandler - Failed to read the overlay list at'\ + document = text + + if not document: + try: + with fileopen(path, 'r') as df: + document = df.read() + except Exception as error: + if not self.ignore_init_read_errors: + msg = 'XML DBHandler - Failed to read the overlay list at'\ '("%(path)s")' % {'path': path} self.output.error(msg) raise error diff --git a/layman/dbbase.py b/layman/dbbase.py index b6c32bc..56ef158 100644 --- a/layman/dbbase.py +++ b/layman/dbbase.py @@ -167,7 +167,7 @@ class DbBase(object): return - def read_db(self, path): + def read_db(self, path, text=None): ''' Read the overlay database for installed overlay definitions. ''' @@ -178,7 +178,7 @@ class DbBase(object): self.ignore, self.ignore_init_read_errors) - db_ctl.read_db(path) + db_ctl.read_db(path, text=text) def write(self, path): diff --git a/layman/remotedb.py b/layman/remotedb.py index e6492f4..cd6ece3 100644 --- a/layman/remotedb.py +++ b/layman/remotedb.py @@ -280,7 +280,7 @@ class RemoteDB(DbBase): def _check_download(self, olist, url): try: - self.read(olist, origin=url) + self.read_db(url, text=olist) except Exception as error: self.output.debug("RemoteDB._check_download(), url=%s \nolist:\n" % url,2) |