[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Using input version string for __str__



commit 8164af5ba0e571dfcd735274e1c4079c79a6fd8d
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
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):
     """



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits