commit:     f45dd7b5e95203540267dccd758f0bc8a69082c3
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 13 16:48:07 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Jul 13 16:48:10 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=f45dd7b5

Code clean-up

overlay.py: Modifies what from_dict() expects in the overlay dictionary
constants.py: Modifies POSSIBLE_COMPONENTS and REQUIRED_COMPONENTS to
reflect change in overlay.py
maker.py: Modifies components that form the overlay dict to follow in
suit of what from_dict() expects.

These changes have been made primarily for uniformity with the
from_xml() function.

 layman/constants.py        |  6 +++---
 layman/maker.py            | 46 +++++++++++++++++++++++-----------------------
 layman/overlays/overlay.py | 11 +++++------
 3 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/layman/constants.py b/layman/constants.py
index 787b610..a39071f 100644
--- a/layman/constants.py
+++ b/layman/constants.py
@@ -63,9 +63,9 @@ SUCCEED = 0
 ##
 
#################################################################################
 
-COMPONENT_DEFAULTS  = ['name', 'descriptions', 'owner', 'type', 'sources']
-POSSIBLE_COMPONENTS = ['name', 'descriptions', 'homepage', 'owner', 'quality',
-                       'priority', 'sources', 'branch', 'irc', 'feeds']
+COMPONENT_DEFAULTS  = ['name', 'description', 'owner', 'type', 'source']
+POSSIBLE_COMPONENTS = ['name', 'description', 'homepage', 'owner', 'quality',
+                       'priority', 'source', 'branch', 'irc', 'feed']
 
 ###############################################################################
 ##

diff --git a/layman/maker.py b/layman/maker.py
index e896530..caf5655 100644
--- a/layman/maker.py
+++ b/layman/maker.py
@@ -42,17 +42,17 @@ else:
     _UNICODE = 'UTF-8'
 
 AUTOCOMPLETE_TEMPLATE = {
-    'bitbucket': {'feeds': (
+    'bitbucket': {'feed': (
                             'http://bitbucket.org/%(tail)s/atom',
                             'http://bitbucket.org/%(tail)s/rss'
                            ),
                   'homepage': 'https://bitbucket.org/%(tail)s',
-                  'sources': (
+                  'source': (
                  ('https://bitbucket.org/%(tail)s', 'mercurial', '%(branch)s'),
                  ('ssh://h...@bitbucket.org/%(tail)s', 'mercurial', 
'%(branch)s')
                  )
                  },
-    'gentoo': {'feeds': (
+    'gentoo': {'feed': (
                          'https://git.overlays.gentoo.org/gitweb/'\
                          '?p=%(tail)s;a=atom',
                          'https://git.overlays.gentoo.org/gitweb/'\
@@ -60,13 +60,13 @@ AUTOCOMPLETE_TEMPLATE = {
                         ),
                'homepage': 'https://git.overlays.gentoo.org/gitweb/'\
                            '?p=%(tail)s;a=summary',
-               'sources': (
+               'source': (
               ('https://git.overlays.gentoo.org/gitroot/%(tail)s', 'git', ''),
               ('git://git.overlays.gentoo.org/%(tail)s', 'git', ''),
               ('git+ssh://g...@git.overlays.gentoo.org/%(tail)s', 'git', '')
               )
               },
-    'gentoo-branch': {'feeds': (
+    'gentoo-branch': {'feed': (
                                 'https://git.overlays.gentoo.org/gitweb/?p='\
                                 '%(tail)s;a=atom;h=refs/heads/%(branch)s',
                                 'https://git.overlays.gentoo.org/gitweb/?p='\
@@ -75,7 +75,7 @@ AUTOCOMPLETE_TEMPLATE = {
                       'homepage': 'https://git.overlays.gentoo.org/gitweb/?p='\
                                   '%(tail)s;a=shortlog;h=refs/heads/'\
                                   '%(branch)s',
-                      'sources': (
+                      'source': (
                      ('https://git.overlays.gentoo.org/gitroot/%(tail)s', 
'git',
                       '%(branch)s'),
                      ('git://git.overlays.gentoo.org/%(tail)s', 'git',
@@ -84,19 +84,19 @@ AUTOCOMPLETE_TEMPLATE = {
                       '%(branch)s')
                      )
                      },
-    'github': {'feeds': ('https://github.com/%(info)s/commits/master.atom',),
+    'github': {'feed': ('https://github.com/%(info)s/commits/master.atom',),
                'homepage': 'https://github.com/%(info)s',
-               'sources': (
+               'source': (
               ('https://github.com/%(tail)s', 'git', ''),
               ('git://github.com/%(tail)s', 'git', ''),
               ('g...@github.com:%(tail)s', 'git', ''),
               ('https://github.com/%(tail)s', 'svn', '')
               )
               },
-    'github-branch': {'feeds': ('https://github.com/%(info)s/commits/'\
+    'github-branch': {'feed': ('https://github.com/%(info)s/commits/'\
                                '%(branch)s.atom'),
                      'homepage': 'https://github.com/%(info)s/tree/%(branch)s',
-                     'sources': (
+                     'source': (
                      ('https://github.com/%(tail)s', 'git', '%(branch)s'),
                      ('git://github.com/%(tail)s', 'git', '%(branch)s'),
                      ('g...@github.com:%(tail)s', 'git', '%(branch)s'),
@@ -261,7 +261,7 @@ class Interactive(object):
             if possible not in self.required:
                 msg = 'Include %(comp)s for this overlay? [y/n]: '\
                         % ({'comp': possible})
-                if ((possible in 'homepage' or possible in 'feeds') and
+                if ((possible in 'homepage' or possible in 'feed') and
                     self.auto_complete):
                     available = False
                 else:
@@ -270,7 +270,7 @@ class Interactive(object):
                     self.required.append(possible)
 
 
-    def get_descriptions(self):
+    def get_description(self):
         '''
         Prompts user for an overlay's description(s)
         and updates overlay dict with value(s).
@@ -282,10 +282,10 @@ class Interactive(object):
         desc = get_input('Define overlay\'s description: ')
         descriptions.append(desc)
 
-        self.overlay['descriptions'] = descriptions
+        self.overlay['description'] = descriptions
 
 
-    def get_feeds(self):
+    def get_feed(self):
         '''
         Prompts user for any overlay RSS feeds
         and updates overlay dict with values.
@@ -301,7 +301,7 @@ class Interactive(object):
             else:
                 feeds.append(get_input('Define overlay feed: '))
 
-        self.overlay['feeds'] = feeds
+        self.overlay['feed'] = feeds
         self.output.notice('')
 
 
@@ -323,7 +323,7 @@ class Interactive(object):
         self.overlay['name'] = name
 
 
-    def get_sources(self):
+    def get_source(self):
         '''
         Prompts user for possible overlay source
         information such as type, url, and branch
@@ -339,7 +339,7 @@ class Interactive(object):
                   'for this overlay?: '
             source_amount = int(get_input(msg))
 
-        self.overlay['sources'] = []
+        self.overlay['source'] = []
 
         for i in range(1, source_amount + 1):
             sources = []
@@ -389,9 +389,9 @@ class Interactive(object):
             if self.auto_complete:
                 sources = self._set_additional_info(sources)
                 for source in sources:
-                    self.overlay['sources'].append(source)
+                    self.overlay['source'].append(source)
             else:
-                self.overlay['sources'].append(sources)
+                self.overlay['source'].append(sources)
         self.output.notice('')
 
 
@@ -415,7 +415,7 @@ class Interactive(object):
         @params msg: (str) prompt message for component
         '''
         if component not in ('branch', 'type'):
-            if component in ('descriptions', 'feeds', 'name', 'owner', 
'sources'):
+            if component in ('description', 'feed', 'name', 'owner', 'source'):
                 getattr(self, 'get_%(comp)s' % ({'comp': component}))()
             else:
                 self.overlay[component] = get_input(msg)
@@ -496,13 +496,13 @@ class Interactive(object):
                 if i in ('bitbucket') and 'git' in (source[1]):
                     return [source]
 
-                for s in TEMPLATE['sources']:
+                for s in TEMPLATE['source']:
                     source = (s[0] % attrs, s[1], s[2] % attrs)
                     sources.append(source)
-                for f in TEMPLATE['feeds']:
+                for f in TEMPLATE['feed']:
                     feed = (f % attrs)
                     feeds.append(feed)
-                self.overlay['feeds'] = feeds
+                self.overlay['feed'] = feeds
 
         if sources:
             return sources

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index e4195cf..423b91e 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -243,7 +243,7 @@ class Overlay(object):
                   % {'name': self.name}
             raise Exception(msg)
 
-        _sources = overlay['sources']
+        _sources = overlay['source']
 
         if _sources == None:
             msg = 'Overlay from_dict(), "%(name)s" is missing a "source"'\
@@ -287,9 +287,9 @@ class Overlay(object):
             elif ignore == 1:
                 self.output.warn(msg, 4)
 
-        if 'descriptions' in overlay:
+        if 'description' in overlay:
             self.descriptions = []
-            _descs = overlay['descriptions']
+            _descs = overlay['description']
             for d in _descs:
                 d = WHITESPACE_REGEX.sub(' ', d)
                 self.descriptions.append(encode(d))
@@ -322,9 +322,9 @@ class Overlay(object):
         else:
             self.homepage = None
 
-        if 'feeds' in overlay:
+        if 'feed' in overlay:
             self.feeds = [encode(e) \
-                for e in overlay['feeds']]
+                for e in overlay['feed']]
         else:
             self.feeds = None
 
@@ -333,7 +333,6 @@ class Overlay(object):
         else:
             self.irc = None
 
-        #xml = self.to_xml()
         # end of from_dict
 
 

Reply via email to