aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-11-29 20:07:51 -0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-11-29 20:07:51 -0200
commitd014e7088833e3013e0eb87ce2d2042b1cc461c3 (patch)
treece42c13a280ce2fac7f865c531750806d1d6572a
parentadded g_octave.checksum module, with tests (diff)
downloadg-octave-d014e7088833e3013e0eb87ce2d2042b1cc461c3.tar.gz
g-octave-d014e7088833e3013e0eb87ce2d2042b1cc461c3.tar.bz2
g-octave-d014e7088833e3013e0eb87ce2d2042b1cc461c3.zip
added checksum support to g_octave.description module, with test
-rw-r--r--g_octave/description.py7
-rw-r--r--tests/test_description.py1
2 files changed, 8 insertions, 0 deletions
diff --git a/g_octave/description.py b/g_octave/description.py
index df0c23e..c0a3fe7 100644
--- a/g_octave/description.py
+++ b/g_octave/description.py
@@ -33,6 +33,7 @@ from contextlib import closing
from .config import Config
from .exception import ConfigException, DescriptionException
from .compat import py3k
+from .checksum import sha1_compute
if py3k:
import urllib.request as urllib
@@ -62,6 +63,8 @@ class Description(object):
log.error('File not found: %s' % file)
raise DescriptionException('File not found: %s' % file)
+ self._file = file
+
# dictionary with the parsed content of the DESCRIPTION file
self._desc = dict()
@@ -259,6 +262,10 @@ class Description(object):
return depends_list
+ def sha1sum(self):
+ return sha1_compute(self._file)
+
+
def __getattr__(self, name):
"""method that overloads the object atributes, returning the needed
atribute based on the dict with the previously parsed content.
diff --git a/tests/test_description.py b/tests/test_description.py
index 9016325..57f933b 100644
--- a/tests/test_description.py
+++ b/tests/test_description.py
@@ -198,6 +198,7 @@ class TestDescription(unittest.TestCase):
self.assertEqual(self.desc.depends, ['>=sci-mathematics/octave-3.0.0'])
self.assertEqual(self.desc.autoload, 'NO')
self.assertEqual(self.desc.license, 'GPL version 3 or later')
+ self.assertEqual(self.desc.sha1sum(), '6538f6e7cd4515ef38e04a9b62da4bebb7496b51')
def tearDown(self):
# removing the temp tree