From d014e7088833e3013e0eb87ce2d2042b1cc461c3 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Mon, 29 Nov 2010 20:07:51 -0200 Subject: added checksum support to g_octave.description module, with test --- g_octave/description.py | 7 +++++++ tests/test_description.py | 1 + 2 files changed, 8 insertions(+) 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 -- cgit v1.2.3-65-gdbad