[tor-bugs] #7654 [Stem]: torrc parser in stem
Tor Bug Tracker & Wiki
blackhole at torproject.org
Sat Dec 8 19:29:04 UTC 2012
#7654: torrc parser in stem
-------------------------+--------------------------------------------------
Reporter: gsathya | Owner: atagar
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: Stem | Version:
Keywords: controller | Parent:
Points: | Actualpoints:
-------------------------+--------------------------------------------------
Comment(by atagar):
Hi Sathyanarayanan. That would be a fine start for a feature branch but
I'd rather not merge it until we have something a bit more complete and
with tests.
Btw, on first glance your parser will break when it encounters blank
lines...
{{{
with open(torrc_path) as torrc_fh:
for line in torrc_fh.readlines():
line = line.strip()
if line.startswith('#'):
continue
else:
key, val = line.split(' ')
torrc[key] = val
}}}
{{{
>>> line = ""
>>> if line.startswith('#'):
... pass
... else:
... key, val = line.split(' ')
...
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
ValueError: need more than 1 value to unpack
}}}
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/7654#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list