[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #4913 [Stem]: Add stem.util.conf.Config.save()
#4913: Add stem.util.conf.Config.save()
-------------------------+--------------------------------------------------
Reporter: gsathya | Owner: atagar
Type: enhancement | Status: needs_revision
Priority: normal | Milestone:
Component: Stem | Version:
Keywords: | Parent:
Points: | Actualpoints:
-------------------------+--------------------------------------------------
Comment(by gsathya):
Replying to [comment:9 atagar]:
> > I'm not sure I follow. Where is this from?
>
> First line after the pydocs in...
>
https://gitweb.torproject.org/user/gsathya/stem.git/commitdiff/4ba49e08ba1d4b07fbb3af87652cd11b3d9fdb9d
>
Oops, Sorry!
> > Yeah, I wanted to do --
> > for entry in sorted(self.iterkeys()):
>
> Oh, good catch - we should use sorted() instead of sort in this case...
>
https://gitweb.torproject.org/user/gsathya/stem.git/commit/56e76d1f206639d15d6e2de7e17732753debc112
> def set(self, key, value, overwrite = True):
> """
> Sets the given key/value configuration mapping, behaving the same as
if we'd
> loaded this from a configuration file.
>
> Arguments:
> key (str) - key for the configuration mapping
> value (str or list) - value we're setting the mapping to
> overwrite (bool) - replaces our current configuration mapping if
True,
> otherwise it's appended to the configuration
> """
>
> This would allow the more intuitive usage that you're expecting.
>
+1 for this. I'll have a go at this.
> > ACK! I just saw that you passed Multiple=True to Config.get_value(),
in your latest commit. Now with the above example, when we call
Config.save() we'd be storing
> >
> > login.password foo bar
> >
> > Right?
>
> Not quite, we'd store...
>
> login.password foo
> login.password bar
>
Yeah I realised this a little too late, hence the facepalm-ing.
> > with open(self._path, 'w') as f:
>
> Oops, good catch. We still need to rename the 'f' variables too...
>
https://gitweb.torproject.org/user/gsathya/stem.git/commit/0479e058e644b89f7a6742e2672e3e0403f4a4ff
> > +# moving along..
>
> Cute, though do we really want to push that? ;)
>
Heh :P
> > #Overwrite settings.
>
> Very minor style things but...
> - please include a space between the hash and comment
> - if your comment is a single sentence then make it all lowercase
without punctuation
>
> examples...
>
> # the following code will implode and destroy the universe
>
> ... or...
>
> # This is a more sizable explanation of said universal doom. More
> # specifically, the following code is gonna divide by zero ripping a
tear in
> # the space-time continuum... we think. Total galactic destruction has
not yet
> # been integration tested.
>
Aha, got it. Thanks for explaining :)
> Each unit or integration test should be for a single use case of a
single method to make testing failures easier to isolate. Test method
names are of the form "test_<method>_<use case>". In this case you'd
probably want the following new test methods...
>
> # this test would...
> # 1. make a config with the example config
> # 2. save it to our integ data directory
> # 3. clear the config
> # 4. load the saved config
> # 5. assert that our configuration has the example contents
> # 6. remove the config we saved
>
> test_save_example()
>
Pushed.
> # similar to the above, but with an empty configuration file
>
> test_save_empty()
>
Pushed.
Will try to push more tests, though I won't be committing much this week,
since my exams start tomorrow. Also, I haven't added the pydoc strings to
the pushed tests. Will do that soon.
https://gitweb.torproject.org/user/gsathya/stem.git/shortlog/refs/heads/integ_test_conf.save_v2
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/4913#comment:11>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs