Changeset 231
- Timestamp:
- 19-05-07 13:30:41 (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
moap/test/test_util_distro.py (modified) (1 diff)
-
moap/util/deps.py (modified) (4 diffs)
-
moap/util/distro.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r230 r231 1 2007-05-19 Thomas Vander Stichele <thomas at apestaart dot org> 2 3 * moap/util/deps.py (Dependency.install, Dependency.fedora_yum, 4 RDF.fedora_install, Cheetah, Cheetah.fedora_install, 5 handleImportError): 6 Add a method to make the yum install output uniform. 7 RDF is not available at all yet in Fedora. 8 Cheeath is though. 9 * moap/util/distro.py (Distro, Distro.atLeast, getDistroFromRelease, 10 _fedora_getNameVersionFromRelease): 11 Rename distro-specific methods internally to make more sense. 12 Add .atLeast to do string-based version comparisons. 13 * moap/test/test_util_distro.py (TestRelease.testFedora, 14 TestRelease.testGet, TestAtLeast, TestAtLeast.testFedora): 15 Add some tests for atLeast 16 17 Coverage: 73 % ( 859 / 1172) 18 1 19 2007-05-19 Thomas Vander Stichele <thomas at apestaart dot org> 2 20 -
trunk/moap/test/test_util_distro.py
r205 r231 10 10 class TestRelease(unittest.TestCase): 11 11 def testFedora(self): 12 self.assertEquals(distro._fedora_get VersionFromRelease(12 self.assertEquals(distro._fedora_getNameVersionFromRelease( 13 13 'Fedora Core release 5 (Bordeaux)\n'), ('Fedora Core', '5')) 14 14 15 15 def testGet(self): 16 16 distro.getDistroFromRelease() 17 18 class TestAtLeast(unittest.TestCase): 19 def testFedora(self): 20 d = distro.Distro('fedora', 'Fedora Core', '5', 'i386') 21 self.failUnless(d.atLeast('4test2')) 22 self.failUnless(d.atLeast('5')) 23 self.failIf(d.atLeast('5test2')) 24 self.failIf(d.atLeast('40')) 25 self.failIf(d.atLeast('50')) -
trunk/moap/util/deps.py
r224 r231 19 19 for the given distro/version/arch. 20 20 21 @type distro: L{distro.Distro} 22 21 23 @rtype: str or None 22 24 @returns: an explanation on how to install the dependency, or None. … … 27 29 return m(distro) 28 30 31 def fedora_yum(self, packageName): 32 """ 33 Returns a string explaining how to install the given package. 34 """ 35 return "On Fedora, you can install %s with:\n" \ 36 "su -c \"yum install %s\"" % (self.module, packageName) 29 37 30 38 class RDF(Dependency): … … 34 42 35 43 def fedora_install(self, distro): 36 if distro.version >= '5': 37 return "You can install RDF on Fedora with:\n" \ 38 "su -c \"yum install python-redland\" -" 44 return "python-redland is not yet available in Fedora Extras.\n" 39 45 40 return "Your version of Fedora does not have python-redland available." 46 class Cheetah(Dependency): 47 module = 'Cheetah' 48 name = "Cheetah templating language" 49 homepage = "http://cheetahtemplate.org/" 50 51 def fedora_install(self, distro): 52 if distro.atLeast('4'): 53 return self.fedora_yum('python-cheetah') 54 55 return "python-cheetah is only available in Fedora 4 or newer.\n" 41 56 42 57 class genshi(Dependency): … … 75 90 module = module.split('.')[0] 76 91 deps = {} 77 for dep in [RDF(), genshi(), pygoogle(), yahoo()]:92 for dep in [RDF(), Cheetah(), genshi(), pygoogle(), yahoo()]: 78 93 deps[dep.module] = dep 79 94 -
trunk/moap/util/distro.py
r204 r231 4 4 import os 5 5 import re 6 7 import distutils.version 6 8 7 9 from moap.util import log … … 12 14 13 15 class Distro: 16 """ 17 @cvar tag: a short lower-case identifier for the distro 18 @type tag: str 19 @cvar name: a longer human-readable name for the distro 20 @type name: str 21 @cvar version: the version of the distro 22 @type version: str 23 @cvar arch: the architecture of the distro 24 @type arch: str 25 """ 14 26 tag = None 15 27 name = None … … 22 34 self.version = version 23 35 self.arch = arch 36 37 def atLeast(self, version): 38 """ 39 @param version: version to compare with 40 @type version: str 41 42 Returns: whether the distro is at least as new as the given version, 43 taking non-numbers into account. 44 """ 45 mine = distutils.version.LooseVersion(self.version) 46 theirs = distutils.version.LooseVersion(version) 47 return mine >= theirs 24 48 25 49 def getSysName(): … … 65 89 h.close() 66 90 version = None 67 f = '_%s_get VersionFromRelease' % distro91 f = '_%s_getNameVersionFromRelease' % distro 68 92 if f in globals().keys(): 69 93 log.debug('distro', "Found version function %r" % f) … … 74 98 75 99 # distro-specific name and version getters 76 def _fedora_getVersionFromRelease(contents): 100 # each getter should return a list of [full name, version] 101 def _fedora_getNameVersionFromRelease(contents): 77 102 matcher = re.compile("^(Fedora Core) release (\d+) .*") 78 103 m = matcher.search(contents)
Note: See TracChangeset
for help on using the changeset viewer.
