aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <brian.dolbec@gmail.com>2010-07-16 07:10:49 -0700
committerBrian Dolbec <brian.dolbec@gmail.com>2010-07-16 07:10:49 -0700
commitdd8b912db7501af18cc06d5cb2c264fc67201772 (patch)
tree9205b61a0e78a2bfb74a9b10e184962a809081bb
parentfix the docstrings to match current input types. (diff)
downloadoverlord-dd8b912db7501af18cc06d5cb2c264fc67201772.tar.gz
overlord-dd8b912db7501af18cc06d5cb2c264fc67201772.tar.bz2
overlord-dd8b912db7501af18cc06d5cb2c264fc67201772.zip
change add_repo and delete_repo to add_repos,
delete_repos to reflect they can take a list. fix the dumb error in get_errors(). change get_info() to get_info_str() and code get_all_info() that returns data instead of the string representation of it.
-rw-r--r--layman/api.py75
1 files changed, 69 insertions, 6 deletions
diff --git a/layman/api.py b/layman/api.py
index b6ff86a..c4e6a15 100644
--- a/layman/api.py
+++ b/layman/api.py
@@ -96,7 +96,7 @@ class LaymanAPI(object):
return repos
- def delete_repo(self, repos):
+ def delete_repos(self, repos):
"""delete the selected repo from the system
@type repos: list of strings or string
@@ -127,7 +127,7 @@ class LaymanAPI(object):
return True
- def add_repo(self, repos):
+ def add_repos(self, repos):
"""installs the seleted repo id
@type repos: list of strings or string
@@ -158,13 +158,72 @@ class LaymanAPI(object):
return True
- def get_info(self, repos):
- """retirves the recorded information about the repo specified by id
+ def get_all_info(self, repos):
+ """retrieves the recorded information about the repo(s)
+ specified by id
@type repos: list of strings or string
@param repos: ['repo-id1', ...] or 'repo-id'
@rtype list of tuples [(str, bool, bool),...]
- @return: dictionary {'id': (info, official, supported)}
+ @return: dictionary of dictionaries
+ {'id1':
+ {'name': str,
+ 'owner_name': str,
+ 'owner_email': str,
+ ' homepage': str,
+ 'description': str,
+ 'src_uris': list of str ['uri1',...]
+ 'src_type': str,
+ 'priority': int,
+ 'quality': str
+ 'status':,
+ 'official': bool,
+ 'supported': bool,
+ },
+ 'id2': {...}
+ }
+ """
+
+ # In progress, has, been coded to the above dict. yet.
+ repos = self._check_repo_type(repos, "get_info")
+ result = {}
+
+ for id in repos:
+ if not self.is_repo(id):
+ self._error(1, UNKNOWN_REPO_ID %id)
+ result[id] = ('', False, False)
+ try:
+ overlay = self._available_db.select(id)
+ except UnknownOverlayException, error:
+ self._error(2, "Error: %s" %str(error))
+ result[id] = ('', False, False)
+ else:
+ result[id] = {
+ 'name': overlay.name,
+ 'owner_name': overlay.owner_name,
+ 'owner_email': overlay.owner_email,
+ 'homepage': overlay.homepage,
+ 'description': overlay.description,
+ 'src_uris': overlay.source_uris(),
+ 'src_type': overlay.sources[0].type,
+ 'priority': overlay.priority,
+ 'quality': overlay.quality,
+ 'status': overlay.status,
+ 'official': overlay.is_official(),
+ 'supported': overlay.is_supported(),
+ },
+
+ return result
+
+
+ def get_info_str(self, repos):
+ """retirves the string representation of the recorded information
+ about the repo(s) specified by id
+
+ @type repos: list of strings or string
+ @param repos: ['repo-id1', ...] or 'repo-id'
+ @rtype list of tuples [(str, bool, bool),...]
+ @return: dictionary {'id': (info string, official, supported)}
"""
repos = self._check_repo_type(repos, "get_info")
result = {}
@@ -319,10 +378,14 @@ class LaymanAPI(object):
def get_errors(self):
"""returns any warning or fatal messages that occurred during
an operation and resets it back to None
+
+ @rtype: list
+ @return: list of error strings
"""
if self._error_messages:
- return self._error_messages[:]
+ messages = self._error_messages[:]
self._error_messages = []
+ return messages
def create_fd():