diff options
author | Richard Jones <richard@mechanicalcat.net> | 2012-10-02 10:46:30 +1000 |
---|---|---|
committer | Richard Jones <richard@mechanicalcat.net> | 2012-10-02 10:46:30 +1000 |
commit | 4ac891fd900d91f35fa9cd6a840a522848eea802 (patch) | |
tree | 0ec8d10cbdea2a2a662a83a2d6280916dd8ca3f9 | |
parent | 340fddb336a8e4616238b4e2971848d1bd191902 (diff) | |
download | decorator-4ac891fd900d91f35fa9cd6a840a522848eea802.tar.gz |
remove workaround and update verlib to the bugfixed implementation
-rw-r--r-- | store.py | 15 | ||||
-rw-r--r-- | verlib.py | 10 |
2 files changed, 10 insertions, 15 deletions
@@ -480,21 +480,14 @@ class Store: # give up if we can't even do that assert norm_version is not None - # actually objectify the version as the formal parsing and - # re-stringification has a bug we need to work around: - # >>> NormalizedVersion('0.0.2.post1') - # NormalizedVersion('0.0.2.post1.z') - norm_version = NormalizedVersion(norm_version) - s_norm_version = str(norm_version) - - norm_to_orig[s_norm_version] = version - current_ordering[s_norm_version] = ordering - versions.append(norm_version) + norm_to_orig[norm_version] = version + current_ordering[norm_version] = ordering + versions.append(NormalizedVersion(norm_version)) # just in case we did modify the new_version we need to update # it for later comparison if version == new_version: - new_version = s_norm_version + new_version = norm_version except Exception: # fall back on the old distutils LooseVersion versions = [] @@ -49,7 +49,7 @@ _VERSION_RE = re.compile(r''' $''', re.VERBOSE) -class NormalizedVersion: +class NormalizedVersion(object): """A rational version. Good: @@ -184,6 +184,8 @@ class NormalizedVersion: if postdev and postdev is not _FINAL_MARKER: if postdev[0] == _FINAL_MARKER[0]: postdev = postdev[1:] + if postdev[-1] == _FINAL_MARKER[0]: + postdev = postdev[:-1] i = 0 while i < len(postdev): if i % 2 == 0: @@ -356,7 +358,7 @@ def _split_predicate(predicate): return comp, NormalizedVersion(version) -class VersionPredicate: +class VersionPredicate(object): """Defines a predicate: ProjectName (>ver1,ver2, ..)""" _operators = {"<": lambda x, y: x < y, @@ -398,7 +400,7 @@ class VersionPredicate: def match(self, version): """Check if the provided version matches the predicates.""" - if isinstance(version, str): + if isinstance(version, basestring): version = NormalizedVersion(version) for operator, predicate in self.predicates: if not self._operators[operator](version, predicate): @@ -458,6 +460,6 @@ def get_version_predicate(requirements): """Return a VersionPredicate object, from a string or an already existing object. """ - if isinstance(requirements, str): + if isinstance(requirements, basestring): requirements = VersionPredicate(requirements) return requirements |