[tor-commits] [stem/master] Using input version string for __str__
atagar at torproject.org
atagar at torproject.org
Tue Dec 13 18:10:36 UTC 2011
commit 8164af5ba0e571dfcd735274e1c4079c79a6fd8d
Author: Damian Johnson <atagar at torproject.org>
Date: Mon Dec 12 18:24:44 2011 -0800
Using input version string for __str__
Originally we reconstructed version strings from its components since that's
all the Version class had (a separate factory translated strings into Version
objects). However, that's no longer the case and much simpler if we just have
the __str__ method provide the constructing string rather than try to recreate
it.
patch by gsathya
---
stem/version.py | 14 +++-----------
1 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/stem/version.py b/stem/version.py
index 214e06a..26080cc 100644
--- a/stem/version.py
+++ b/stem/version.py
@@ -94,6 +94,7 @@ class Version:
ValueError if input isn't a valid tor version
"""
+ self.version_str = version_str
m = re.match(r'^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?(-\S*)?$', version_str)
if m:
@@ -114,19 +115,10 @@ class Version:
def __str__(self):
"""
- Provides the normal representation for the version, for instance:
- "0.2.2.23-alpha"
+ Provides the string used to construct the Version.
"""
- suffix = ""
-
- if self.patch:
- suffix += ".%i" % self.patch
-
- if self.status:
- suffix += "-%s" % self.status
-
- return "%i.%i.%i%s" % (self.major, self.minor, self.micro, suffix)
+ return self.version_str
def __cmp__(self, other):
"""
More information about the tor-commits
mailing list