A very simple Torrc parser, not in stem's standards by any measure. I just made this for my needs. Thought it might be useful if I push it upstream in case anyone wants to expand on this.
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
Hey, thanks for the review. Yep, this is super trivial as I mentioned, definitely not good enough to be merged. I will try to work on this more, but no promises.