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

[tor-commits] [stem/master] Build StreamClosureReason as a superset of RelayEndReason



commit 545f251b698281b5cd6bd3f704242c9fdafaa36b
Author: Sean Robinson <seankrobinson@xxxxxxxxx>
Date:   Sat Dec 8 19:24:28 2012 -0700

    Build StreamClosureReason as a superset of RelayEndReason
    
    Explicitly make StreamClosureReason rely on RelayEndReason for its
    contents.
    
    Signed-off-by: Sean Robinson <seankrobinson@xxxxxxxxx>
---
 stem/__init__.py |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/stem/__init__.py b/stem/__init__.py
index 5eb6737..092413b 100644
--- a/stem/__init__.py
+++ b/stem/__init__.py
@@ -574,24 +574,16 @@ StreamStatus = stem.util.enum.UppercaseEnum(
   "CLOSED",
 )
 
-StreamClosureReason = stem.util.enum.UppercaseEnum(
-  "MISC",
-  "RESOLVEFAILED",
-  "CONNECTREFUSED",
-  "EXITPOLICY",
-  "DESTROY",
-  "DONE",
-  "TIMEOUT",
-  "NOROUTE",
-  "HIBERNATING",
-  "INTERNAL",
-  "RESOURCELIMIT",
-  "CONNRESET",
-  "TORPROTOCOL",
-  "NOTDIRECTORY",
+# add STREAM event specific reasons to the list of RELAY_END reasons
+_tmp_StreamClosureReason = [v for v in RelayEndReason]
+_tmp_StreamClosureReason.extend((
   "END",
   "PRIVATE_ADDR",
-)
+))
+# build UppercaseEnum from extended list
+StreamClosureReason = stem.util.enum.UppercaseEnum(*_tmp_StreamClosureReason)
+# remove temporary list
+del _tmp_StreamClosureReason
 
 StreamSource = stem.util.enum.UppercaseEnum(
   "CACHE",



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