[tor-bugs] #8306 [Stem]: Format sanitized bridge descriptors and Torperf measurement results

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Feb 22 16:18:57 UTC 2013


#8306: Format sanitized bridge descriptors and Torperf measurement results
------------------------------+---------------------------------------------
 Reporter:  karsten           |          Owner:  atagar
     Type:  enhancement       |         Status:  new   
 Priority:  normal            |      Milestone:        
Component:  Stem              |        Version:        
 Keywords:  descriptors easy  |         Parent:  #8252 
   Points:                    |   Actualpoints:        
------------------------------+---------------------------------------------
Changes (by atagar):

  * keywords:  => descriptors easy


Comment:

 Certainly very easy to do. I'm gonna leave this to potential volunteers
 for now but if this ever becomes the slightest thorn in your side then let
 me know and I'll make it so.

 At a guess what we'll want is...

 * A new static method on the Descriptor class, of the form
 'create_from(attr, instance = None)'. Attr could be either a Descriptor or
 dict. The instance is an optional copy of a descriptor we're cloning to (a
 fresh instance is created if None).

 All this method does is call setattr() to clone all of the attributes from
 the attr to the instance.

 * All Descriptor subclasses would want to override create_from() so when
 instance is undefined they create one of their own type. For instance, the
 RelayDescriptor's copy might look like...

 {{{
 def create_from(attr, instance = None):
   if instance is None:
     instance = RelayDescriptor()

   if not isinstance(instance, RelayDescriptor):
     raise ValueError("RelayDescriptor.create_from() can only clone to a
 RelayDescriptor")

   return Descriptor.create_from(attr, instance)
 }}}

 * We'll need to shift stuff around in all of the __init__ methods to allow
 us to create empty descriptors (the current parsing stuff should probably
 be moved to static methods).

 If someone wants to take this up then feel free to ask me if you have any
 questions.

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/8306#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list