From 9d868538bcd82d8161a53c8b26e5b5e662fda77e Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 10 Dec 2010 15:00:27 -0200 Subject: added P/PN/PV to the description object. some tests are broken. --- g_octave/description.py | 18 ++++++++++++++---- tests/files/DESCRIPTION | 22 ---------------------- tests/files/pkg-0.0.1.DESCRIPTION | 22 ++++++++++++++++++++++ tests/test_description.py | 16 ++++++++-------- 4 files changed, 44 insertions(+), 34 deletions(-) delete mode 100644 tests/files/DESCRIPTION create mode 100644 tests/files/pkg-0.0.1.DESCRIPTION diff --git a/g_octave/description.py b/g_octave/description.py index e7d3680..243a231 100644 --- a/g_octave/description.py +++ b/g_octave/description.py @@ -50,10 +50,15 @@ conf = Config() re_depends = re.compile(r'^([a-zA-Z0-9-]+) *(\( *([><=]?=?) *([0-9.]+) *\))?') # we'll use atoms like 'control-1.0.11' for g-octave packages -re_pkg_atom = re.compile(r'^(.+)-([0-9.]+)$') +re_pkg_atom = re.compile(r'^((.+)-([0-9.]+))\.DESCRIPTION$') class Description(object): - + + # gentoo ebuild variables + P = None + PN = None + PV = None + def __init__(self, file, parse_sysreq=True): log.info('Parsing file: %s' % file) @@ -63,9 +68,14 @@ class Description(object): raise DescriptionException('File not found: %s' % file) self._file = file - self._info = Info(os.path.join(conf.db, 'info.json')) - + + my_atom = re_pkg_atom.match(os.path.basename(self._file)) + if my_atom is not None: + self.P = my_atom.group(1) + self.PN = my_atom.group(2) + self.PV = my_atom.group(3) + # dictionary with the parsed content of the DESCRIPTION file self._desc = dict() diff --git a/tests/files/DESCRIPTION b/tests/files/DESCRIPTION deleted file mode 100644 index d02ceea..0000000 --- a/tests/files/DESCRIPTION +++ /dev/null @@ -1,22 +0,0 @@ -# This is a comment -Name: package name -Version: 0.0.1 -Date: 2009-01-01 -Author: Author Name: testing ':'s in the value. -Maintainer: Maintainer Name -Title: Package Title -# This is another comment -Description: Lorem ipsum dolor sit amet, consectetur adipisicing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi - ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit - in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur - sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt - mollit anim id est laborum. -Categories: Category1,Category2, Category3 -Url: http://example.org -SystemRequirements: pkg11 ( >= 4.3.2), pkg12 (<1.2.3 ), pkg13 -BuildRequires: pkg14 (>1.0.0) -Depends: Octave ( >= 3.0.0 ) -Autoload: NO -License: GPL version 3 or later diff --git a/tests/files/pkg-0.0.1.DESCRIPTION b/tests/files/pkg-0.0.1.DESCRIPTION new file mode 100644 index 0000000..d02ceea --- /dev/null +++ b/tests/files/pkg-0.0.1.DESCRIPTION @@ -0,0 +1,22 @@ +# This is a comment +Name: package name +Version: 0.0.1 +Date: 2009-01-01 +Author: Author Name: testing ':'s in the value. +Maintainer: Maintainer Name +Title: Package Title +# This is another comment +Description: Lorem ipsum dolor sit amet, consectetur adipisicing elit, + sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi + ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit + in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur + sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt + mollit anim id est laborum. +Categories: Category1,Category2, Category3 +Url: http://example.org +SystemRequirements: pkg11 ( >= 4.3.2), pkg12 (<1.2.3 ), pkg13 +BuildRequires: pkg14 (>1.0.0) +Depends: Octave ( >= 3.0.0 ) +Autoload: NO +License: GPL version 3 or later diff --git a/tests/test_description.py b/tests/test_description.py index e6044ff..3688dd1 100644 --- a/tests/test_description.py +++ b/tests/test_description.py @@ -23,7 +23,7 @@ class TestDescription(testcase.TestCase): testcase.TestCase.setUp(self) self.desc = description.Description( os.path.join( - os.path.dirname(os.path.abspath(__file__)), 'files', 'DESCRIPTION', + os.path.dirname(os.path.abspath(__file__)), 'files', 'pkg-0.0.1.DESCRIPTION', ), ) @@ -160,16 +160,13 @@ class TestDescription(testcase.TestCase): def test_re_pkg_atom(self): depends = [ - ('pkg-1', ('pkg', '1')), - ('pkg-1.0', ('pkg', '1.0')), - ('pkg-1.0.0', ('pkg', '1.0.0')), + ('pkg-1.DESCRIPTION', ('pkg-1', 'pkg', '1')), + ('pkg-1.0.DESCRIPTION', ('pkg-1.0', 'pkg', '1.0')), + ('pkg-1.0.0.DESCRIPTION', ('pkg-1.0.0', 'pkg', '1.0.0')), ] for pkgstr, pkgtpl in depends: match = description.re_pkg_atom.match(pkgstr) - self.assertEqual( - (match.group(1), match.group(2)), - pkgtpl - ) + self.assertEqual((match.group(1), match.group(2), match.group(3)), pkgtpl) def test_attributes(self): # TODO: split this method to improve the error reporting @@ -183,6 +180,9 @@ class TestDescription(testcase.TestCase): self.assertEqual(self.desc.description, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.') self.assertEqual(self.desc.categories, 'Category1,Category2, Category3') self.assertEqual(self.desc.url, 'http://example.org') + self.assertEqual(self.desc.P, 'pkg-0.0.1') + self.assertEqual(self.desc.PN, 'pkg') + self.assertEqual(self.desc.PV, '0.0.1') requirements = [ '