aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-12-10 15:00:27 -0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-12-10 15:00:27 -0200
commit9d868538bcd82d8161a53c8b26e5b5e662fda77e (patch)
treea92e88552b7f524e5ffa43e0e0278be06593c745
parentsmall fixes (diff)
downloadg-octave-9d868538bcd82d8161a53c8b26e5b5e662fda77e.tar.gz
g-octave-9d868538bcd82d8161a53c8b26e5b5e662fda77e.tar.bz2
g-octave-9d868538bcd82d8161a53c8b26e5b5e662fda77e.zip
added P/PN/PV to the description object. some tests are broken.
-rw-r--r--g_octave/description.py18
-rw-r--r--tests/files/pkg-0.0.1.DESCRIPTION (renamed from tests/files/DESCRIPTION)0
-rw-r--r--tests/test_description.py16
3 files changed, 22 insertions, 12 deletions
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/pkg-0.0.1.DESCRIPTION
index d02ceea..d02ceea 100644
--- a/tests/files/DESCRIPTION
+++ b/tests/files/pkg-0.0.1.DESCRIPTION
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 = [
'<g-octave/pkg12-1.2.3',