diff options
author | 2015-08-27 23:37:32 -0400 | |
---|---|---|
committer | 2015-08-27 23:40:15 -0400 | |
commit | 794f56f5ae531a5b24200ad3c0d6cf7112305da8 (patch) | |
tree | 35699d1071277270fcba335d05f4766e596f4daa | |
parent | overlay.py: Modifies __eq__ attribute requirements (diff) | |
download | layman-794f56f5ae531a5b24200ad3c0d6cf7112305da8.tar.gz layman-794f56f5ae531a5b24200ad3c0d6cf7112305da8.tar.bz2 layman-794f56f5ae531a5b24200ad3c0d6cf7112305da8.zip |
Deprecates get_all_info() function
The api function get_all_info() is being deprecated as it was much
slower than the get_info_str() function and was no longer used in
layman's code. The only instance found making use of it was older test
code which has been changed to also use the get_info_str() function.
external.py: Deprecates the get_all_info() function and adds multiple
owner testing compatibility.
api.py: Removes the get_all_info() function.
cli.py: Removes commented out use of get_all_info() function.
global-overlays.json: Changes structure of 'owner' attribute to reflect
changes for multiple owner support.
-rwxr-xr-x | layman/api.py | 69 | ||||
-rw-r--r-- | layman/cli.py | 6 | ||||
-rwxr-xr-x | layman/tests/external.py | 40 | ||||
-rw-r--r-- | layman/tests/testfiles/global-overlays.json | 12 |
4 files changed, 22 insertions, 105 deletions
diff --git a/layman/api.py b/layman/api.py index 0718dce..20fe402 100755 --- a/layman/api.py +++ b/layman/api.py @@ -237,75 +237,6 @@ class LaymanAPI(object): return True - def get_all_info(self, repos, local=False): - """retrieves the recorded information about the repo(s) - specified by repo-id - - @type repos: list of strings or string - @param repos: ['repo-id1', ...] or 'repo-id' - @rtype list of tuples [(str, bool, bool),...] - @return: dictionary of dictionaries - {'ovl1': - {'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, - }, - 'ovl2': {...} - } - """ - - repos = self._check_repo_type(repos, "get_info") - result = {} - - if local: - db = self._get_installed_db() - else: - db = self._get_remote_db() - - for ovl in repos: - if not self.is_repo(ovl): - self.output.error(UnknownOverlayMessage(ovl)) - result[ovl] = ('', False, False) - continue - try: - overlay = db.select(ovl) - except UnknownOverlayException as error: - self._error(error) - result[ovl] = ('', False, False) - else: - result[ovl] = { - 'name': overlay.name, - 'owner_name': overlay.owner_name, - 'owner_email': overlay.owner_email, - 'homepage': overlay.homepage, - 'irc': overlay.irc, - 'description': [e for e in overlay.descriptions], - 'feeds': overlay.feeds, - 'sources': [(e.src, e.type, e.branch) \ - for e in overlay.sources], - #'src_uris': [e.src for e in overlay.sources], - 'src_uris': overlay.source_uris(), - 'src_types': overlay.source_types(), - #'src_types': [e.type for e in overlay.sources], - '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, local=True, verbose=False, width=0): """retrieves the string representation of the recorded information about the repo(s) specified by ovl diff --git a/layman/cli.py b/layman/cli.py index bb9ea6f..86d6e70 100644 --- a/layman/cli.py +++ b/layman/cli.py @@ -381,17 +381,11 @@ class Main(object): self.output.debug('Printing installed overlays.', 6) list_printer = ListPrinter(self.config) - # - # fast way info = self.api.get_info_list(verbose=self.config['verbose'], width=list_printer.width) #self.output.debug('CLI: ListLocal() info = %s' % len(info), 4) #self.output.debug('\n'.join([ str(x) for x in info]), 4) list_printer.print_shortlist(info, complain=True) - # - # slow way - #info = self.api.get_all_info(self.api.get_installed(), local=True) - #list_printer.print_fulldict(info, complain=_complain) # blank newline -- no " *" self.output.notice('') diff --git a/layman/tests/external.py b/layman/tests/external.py index f61d4b6..f2b18cd 100755 --- a/layman/tests/external.py +++ b/layman/tests/external.py @@ -427,6 +427,7 @@ class FetchRemoteList(unittest.TestCase): my_opts = { 'overlays': ['file://'\ + HERE + '/testfiles/global-overlays.xml'], + 'db_type': 'xml', 'cache': cache, 'nocheck': 'yes', 'proxy': None, @@ -441,7 +442,9 @@ class FetchRemoteList(unittest.TestCase): filename = api._get_remote_db().filepath(config['overlays']) + '.xml' with fileopen(filename, 'r') as b: - self.assertEqual(b.readlines()[19], ' A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org].\n') + description = b.readlines()[19] + self.assertEqual(description, ' A collection of ebuilds from '\ + 'Gunnar Wrobel [wrobel@gentoo.org].\n') for line in b.readlines(): print(line, end='') @@ -449,29 +452,16 @@ class FetchRemoteList(unittest.TestCase): available = api.get_available() self.assertEqual(available, ['wrobel', 'wrobel-stable']) - # Test the info of an overlay. - all_info = api.get_all_info('wrobel') - - test_info = {'status': 'official', 'owner_name': None, - 'description': ['Test'], 'src_uris': - ['https://overlays.gentoo.org/svn/dev/wrobel'], - 'owner_email': 'nobody@gentoo.org', 'sources': - [('https://overlays.gentoo.org/svn/dev/wrobel', - 'Subversion', None)], 'quality': 'experimental', 'name': - 'wrobel', 'supported': True, 'src_types': ['Subversion'], - 'official': True, 'priority': 10, 'feeds': [], - 'irc': None, 'homepage': None} - info = all_info['wrobel'] - info['src_uris'] = [e for e in info['src_uris']] - info['src_types'] = [e for e in info['src_types']] - self.assertEqual(info, test_info) + # Test the info of an overlay. + info = api.get_info_str(['wrobel'], verbose=True, local=False) + test_info = 'wrobel\n~~~~~~\nSource : https://overlays.gentoo.org'\ + '/svn/dev/wrobel\nContact : nobody@gentoo.org\nType '\ + ': Subversion; Priority: 10\nQuality : experimental\n\n'\ + 'Description:\n Test\n' - self.assertEqual(info['status'], 'official') - self.assertEqual(info['description'], ['Test']) - sources = [('https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', - None)] - self.assertEqual(info['sources'], sources) + info = info['wrobel'][0].decode('utf-8') + self.assertEqual(info, test_info) os.unlink(filename) shutil.rmtree(tmpdir) @@ -523,8 +513,7 @@ class MakeOverlayXML(unittest.TestCase): ovl_dict = { 'name': 'wrobel', 'description': ['Test'], - 'owner_name': 'nobody', - 'owner_email': 'nobody@gentoo.org', + 'owner': [{'name': 'nobody', 'email': 'nobody@gentoo.org'}], 'status': 'official', 'source': [['https://overlays.gentoo.org/svn/dev/wrobel', 'svn', '']], @@ -555,13 +544,12 @@ class OverlayObjTest(unittest.TestCase): document = ET.parse(HERE + '/testfiles/global-overlays.xml') overlays = document.findall('overlay') + document.findall('repo') output = Message() - ovl_a = Overlay({'output': output, 'db_type': 'xml'}, xml=overlays[0]) self.assertEqual(ovl_a.name, 'wrobel') self.assertEqual(ovl_a.is_official(), True) url = ['https://overlays.gentoo.org/svn/dev/wrobel'] self.assertEqual(list(ovl_a.source_uris()), url) - self.assertEqual(ovl_a.owner_email, 'nobody@gentoo.org') + self.assertEqual(ovl_a.owners[0]['email'], 'nobody@gentoo.org') self.assertEqual(ovl_a.descriptions, ['Test']) self.assertEqual(ovl_a.priority, 10) diff --git a/layman/tests/testfiles/global-overlays.json b/layman/tests/testfiles/global-overlays.json index 53267cf..6ff4f45 100644 --- a/layman/tests/testfiles/global-overlays.json +++ b/layman/tests/testfiles/global-overlays.json @@ -14,10 +14,12 @@ ], "homepage": "https://github.com/twitch153/ebuilds", "name": "twitch153", - "owner": { + "owner": [ + { "email": "twitch153@gentoo.org", "name": "Devan Franchini" - }, + } + ], "source": [ { "#text": "git://github.com/twitch153/ebuilds.git", @@ -30,9 +32,11 @@ "A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org]." ], "name": "wrobel-stable", - "owner": { + "owner": [ + { "email": "nobody@gentoo.org" - }, + } + ], "source": [ { "#text": "rsync://gunnarwrobel.de/wrobel-stable", |