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

[tor-commits] [stem/master] Condensing basic example a tiny bit



commit 149d1bd2932a093ffe7fb75298da9b442b3b64c7
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Mar 13 09:19:48 2012 -0700

    Condensing basic example a tiny bit
    
    Combining the constructor and 'with' lines since that's probably the common
    case. The second example already shows a standalone constructor anyway.
---
 stem/descriptor/reader.py       |    4 +---
 test/integ/descriptor/reader.py |    3 +--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index ca987e8..8117361 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -8,10 +8,8 @@ descriptor data in a series of destinations. For example...
     "/tmp/archived_descriptors/",
   ]
   
-  reader = DescriptorReader(my_descriptors)
-  
   # prints the contents of all the descriptor files
-  with reader:
+  with DescriptorReader(my_descriptors) as reader:
     for descriptor in reader:
       print descriptor
 
diff --git a/test/integ/descriptor/reader.py b/test/integ/descriptor/reader.py
index 0344b99..55644b4 100644
--- a/test/integ/descriptor/reader.py
+++ b/test/integ/descriptor/reader.py
@@ -150,10 +150,9 @@ class TestDescriptorReader(unittest.TestCase):
     
     # running this test multiple times to flush out concurrency issues
     for i in xrange(15):
-      reader = stem.descriptor.reader.DescriptorReader([descriptor_path])
       remaining_entries = list(descriptor_entries)
       
-      with reader:
+      with stem.descriptor.reader.DescriptorReader([descriptor_path]) as reader:
         for descriptor in reader:
           descriptor_str = str(descriptor)
           



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