Closed sambuddhabasu closed 9 years ago
@meejah Let me know if the method looks fine. If everything looks good then, I will go ahead and add tests for the method.
To work with the rest of the magic accessors of TorInfo, you'll need to arrange for this method to be called when accessing desc.name.<descriptor name>
or desc.id.<descriptor fingerprint>
-- once TorInfo is setup it hides all members except via the dotted-names things.
So -- you should be able to access descriptors with TorInfo right now on master without any changes...you'll just want to intercept those accesses in case use_stem
is True in the underlying protocol and return Stem objects instead.
@meejah I do not understand the MagicContainer class completely and hence I am having trouble converting the _get_descriptor()
method into something like, desc.name.<descriptor name>
as you mentioned in the above comment.
Can you shed more light on the conversion to dotted object please?
Well, the above dotted-stuff should work right now I believe; basically the magic-container is translating those into "GETINFO desc/name/info/names
ended with a *
or simply into "GETINFO foo/bar" (from foo.bar
) if the meta-information about that key did not end with a *.
So essentially during setup you'll have to figure out if usestem is set, and if so intercept the setup of certain keys and replace with a suitable other method (so you'd be intercepting "desc/name/" and "desc/id/_" or so).
@meejah I have added a new commit, https://github.com/meejah/txtorcon/commit/de88b1614ec842e3704924c4254d99aa47bf40b8
In this commit, I have added a new _get_descriptor method which is called when the use_stem flag is set to True
and the desc.name()
or desc.id()
is called.
Let me know if this is what is required, then, I will add appropriate comments for the method, tests for the method and squash all the commits into one.
@meejah Added test for the _parse_stem_descriptor method. If the code looks good, I will squash all the commits into one. Thanks
yes, looks great!
...and yes please squash (and just change the commit-comment to a description of the whole change instead of leaving the individual commit-comments).
@meejah Made the required changes. This PR can be merged now. Thanks
looks great, thanks for the patch :)
Implemented _get_descriptor() method The parameters for the method are,
nickname
,fingerprint
. These are the relay's nickname/fingerprint for which we want the descriptor information. Returns the descriptor information. If use_stem is set to True, astem.descriptor.server_descriptor.RelayDescriptor
object is returned with the descriptor information.