From: fuzzyray Date: Wed, 6 Jan 2010 15:54:37 +0000 (-0000) Subject: Merge genscripts revision 144, contains fixes for Bug 299260 X-Git-Tag: gentoolkit-0.3.0_rc10~24 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2212da8d45f122c17fce56ed0c1bc57d4387f95c;p=gentoolkit.git Merge genscripts revision 144, contains fixes for Bug 299260 svn path=/trunk/gentoolkit/; revision=729 --- diff --git a/DEVELOPING b/DEVELOPING index 0a6c309..e8b7ab3 100644 --- a/DEVELOPING +++ b/DEVELOPING @@ -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. diff --git a/pym/gentoolkit/atom.py b/pym/gentoolkit/atom.py index ac49dab..3523d60 100644 --- a/pym/gentoolkit/atom.py +++ b/pym/gentoolkit/atom.py @@ -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) diff --git a/pym/gentoolkit/cpv.py b/pym/gentoolkit/cpv.py index e5b4a48..9b3c2d7 100644 --- a/pym/gentoolkit/cpv.py +++ b/pym/gentoolkit/cpv.py @@ -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 diff --git a/pym/gentoolkit/dependencies.py b/pym/gentoolkit/dependencies.py index ccc241e..9ff7f90 100644 --- a/pym/gentoolkit/dependencies.py +++ b/pym/gentoolkit/dependencies.py @@ -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: diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py index 18e08af..759ecba 100644 --- a/pym/gentoolkit/equery/depends.py +++ b/pym/gentoolkit/equery/depends.py @@ -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(']')) diff --git a/pym/gentoolkit/test/test_atom.py b/pym/gentoolkit/test/test_atom.py index ea85e2a..4a1568b 100644 --- a/pym/gentoolkit/test/test_atom.py +++ b/pym/gentoolkit/test/test_atom.py @@ -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-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), ]: