Merge genscripts revision 144, contains fixes for Bug 299260
authorfuzzyray <fuzzyray@gentoo.org>
Wed, 6 Jan 2010 15:54:37 +0000 (15:54 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Wed, 6 Jan 2010 15:54:37 +0000 (15:54 -0000)
svn path=/trunk/gentoolkit/; revision=729

DEVELOPING
pym/gentoolkit/atom.py
pym/gentoolkit/cpv.py
pym/gentoolkit/dependencies.py
pym/gentoolkit/equery/depends.py
pym/gentoolkit/test/test_atom.py

index 0a6c3099406963ba3cff6ee521fca421ec8b5b7f..e8b7ab35f135a46ba4e788d3b0b23c1d140cd140 100644 (file)
@@ -1,5 +1,5 @@
 Python Code Guidelines
----------------
+----------------------
 These are a few guidelines to stick to when modifying or adding code to
 Gentoolkit. These guidelines do not apply to pym/gentoolkit/test/*.
 
@@ -33,7 +33,7 @@ Line-Wrapping
       ...
   )
 
-- Max. line length is strictly 80 characters with a tab length of 4 characters.
+- Preferred line length is 80 characters with a tab length of 4 characters.
 - "The preferred way of wrapping long lines is by using Python's implied line
   continuation inside parentheses, brackets and braces" rather than using '\'
   (PEP 8).
@@ -47,12 +47,12 @@ Line-Wrapping
     self._descriptions = \
         [e.text for e in self._xml_tree.findall("longdescription")]
 
-  BETTER:
+  OK:
     self._descriptions = [
         e.text for e in self._xml_tree.findall("longdescription")
     ]
 
-  BEST: (easiest to read and test)
+  OK: (easiest to read and test)
     long_descriptions = self._xml_tree.findall("longdescription")
     self._descriptions = [e.text for e in long_descriptions]
 
@@ -153,14 +153,9 @@ something tricky about them, though.
 Other concerns:
 ---------------
 - Choose names which are full, clear words (not necessary in small loops).
-- It is NEVER necessary to prefix names with "my". Consider:
-    class FooThinger(object):
-        def __init__(self, foo):
-            self.myfoo = foo
-
-  Just use FooThinger.foo or FooThinger.orig_foo; "my"foo tells us nothing.
+- It is NEVER necessary to prefix names with "my". It adds no useful
+  information.
 - Comment and document in simple, unambiguous and non-repetitive English.
 - When adding a TODO, FIXME or XXX comment, please date it and add your name so
   that other devs know who to ask about the proposed change.
-- Be careful of spelling. DO spell check your source code and be professional
-  when writing comments.
+- Be careful of spelling.
index ac49dab79b97b867eb83775f2ff2f2f0ee9f4d0a..3523d606aa2f0a4ef2ad6c2df752f1f37fd85dde 100644 (file)
@@ -68,14 +68,7 @@ class Atom(portage.dep.Atom, CPV):
 
                # Make operator compatible with intersects
                if self.operator is None:
-                       self.operator = '='
-
-               # Make slot a tuple if defined
-               # pylint screwup:
-               # E1101: 75:Atom.__init__: Instance of 'tuple' has no 'split' member
-               # pylint: disable-msg=E1101
-               if self.slot is not None:
-                       self.slot = tuple(sorted(self.slot.split(',')))
+                       self.operator = ''
 
                self.cpv = CPV(self.cpv)
 
index e5b4a486c799fb45aaafd0be703f71db17604fbf..9b3c2d77fcb01c386d3cff59c9adc42765bb99ae 100644 (file)
@@ -36,11 +36,10 @@ class CPV(object):
                'sys-apps/portage-2.2-r1'
                >>> # An 'rc' (release candidate) version is less than non 'rc' version:
                ... CPV('sys-apps/portage-2') > CPV('sys-apps/portage-2_rc10')
+               True
        """
 
        def __init__(self, cpv):
-               if not cpv:
-                       raise errors.GentoolkitInvalidCPV(cpv)
                self.scpv = cpv
 
                values = split_cpv(cpv)
@@ -131,6 +130,7 @@ def split_cpv(cpv):
 
        Inlined from helpers because of circular imports.
 
+       @todo: this function is slow and accepts some crazy things for cpv
        @type cpv: str
        @param cpv: pkg, cat/pkg, pkg-ver, cat/pkg-ver, atom or regex
        @rtype: tuple
index ccc241e3365f60ffe7b53bf3b283f1b0debce4c5..9ff7f905cd2e2a5d9f28391a45fff6bc0a739f9b 100644 (file)
@@ -303,8 +303,12 @@ class Dependencies(CPV):
                                use_conditional = tok[:-1]
                                continue
                        if isinstance(tok, list):
-                               asdf = self._parser(tok, use_conditional, depth=depth+1)
-                               result.extend(asdf)
+                               sub_r = self._parser(tok, use_conditional, depth=depth+1)
+                               result.extend(sub_r)
+                               use_conditional = None
+                               continue
+                       if tok[0] == '!':
+                               # We're not interested in blockers
                                continue
                        atom = Atom(tok)
                        if use_conditional is not None:
index 18e08afbd373110ad85b0b9953104c6d331ef8a7..759ecba983ceb4673e0db94354dac938ccb800fe 100644 (file)
@@ -81,7 +81,7 @@ class DependPrinter(object):
                else:
                        formatted_dep = mdep.operator + str(mdep.cpv)
                if mdep.slot:
-                       formatted_dep += pp.emph(':') + pp.slot(','.join(mdep.slot))
+                       formatted_dep += pp.emph(':') + pp.slot(mdep.slot)
                if mdep.use:
                        useflags = pp.useflag(','.join(mdep.use.tokens))
                        formatted_dep += (pp.emph('[') + useflags + pp.emph(']'))
index ea85e2a26d729e0da99e72153b0e2823167ab921..4a1568b81cd74f90f9446914d02cb4394a2fe573 100644 (file)
@@ -71,8 +71,8 @@ class TestGentoolkitAtom(unittest.TestCase):
                # slots.
                self.assertNotEqual2(Atom('cat/pkg:1'), Atom('cat/pkg'))
                self.assertEqual2(Atom('cat/pkg:2'), Atom('cat/pkg:2'))
-               self.assertEqual2(Atom('cat/pkg:2,1'), Atom('cat/pkg:2,1'))
-               self.assertEqual2(Atom('cat/pkg:2,1'), Atom('cat/pkg:1,2'))
+               # http://dev.gentoo.org/~tanderson/pms/eapi-2-approved/pms.html#x1-190002.1.2
+               self.assertEqual2(Atom('cat/pkg:AZaz09+_.-'), Atom('cat/pkg:AZaz09+_.-'))
                for lesser, greater in (('0.1', '1'), ('1', '1-r1'), ('1.1', '1.2')):
                        self.assertTrue(Atom('=d/b-%s' % lesser) <
                                Atom('=d/b-%s' % greater),
@@ -126,8 +126,9 @@ class TestGentoolkitAtom(unittest.TestCase):
                        ('=cat/pkg-1-r1*', '<cat/pkg-1-r1', False),
                        ('=cat/pkg-1*', '>cat/pkg-2', False),
                        ('>=cat/pkg-8.4', '=cat/pkg-8.3.4*', False),
-                       ('cat/pkg::gentoo', 'cat/pkg', True),
-                       ('cat/pkg::gentoo', 'cat/pkg::foo', False),
+                       # Repos not yet supported by Portage
+                       #('cat/pkg::gentoo', 'cat/pkg', True),
+                       #('cat/pkg::gentoo', 'cat/pkg::foo', False),
                        ('=sys-devel/gcc-4.1.1-r3', '=sys-devel/gcc-3.3*', False),
                        ('=sys-libs/db-4*', '~sys-libs/db-4.3.29', True),
                ]: