Opened 6 years ago

Last modified 18 months ago

#8306 new enhancement

Format sanitized bridge descriptors and Torperf measurement results

Reported by: karsten Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Normal Keywords: descriptors easy
Cc: Actual Points:
Parent ID: #8252 Points:
Reviewer: Sponsor:


Stem has lots of code for parsing dir-spec.txt objects and metrics-related extensions. I could also make use of functionality to build objects, either based on previously parsed descriptors, or from scratch. I'd use this functionality to create sanitized bridge descriptors (where the order of keywords should be preserved, but where I can replace arguments or add/remove keywords), to format Torperf measurement results, etc. There would likely be just a single application using this code, but it seems useful to maintain this code together with the parsing code. There's no metrics-lib equivalent for this.

Child Tickets

Change History (2)

comment:1 Changed 6 years ago by atagar

Keywords: descriptors easy added

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.

comment:2 Changed 18 months ago by teor

Severity: Normal

Set all open tickets without a severity to "Normal"

Note: See TracTickets for help on using tickets.