Opened 8 years ago

Closed 7 years ago

#7654 closed enhancement (duplicate)

torrc parser in stem

Reported by: gsathya Owned by: atagar
Priority: Low Milestone:
Component: Archived/Stem Version:
Severity: Keywords: controller
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description (last modified by atagar)

Arm has a pretty nice parser and validator for Tor's torrc...

We should port it and the man page parser over to stem, adding tests when we do so.

Child Tickets

Change History (5)

comment:1 Changed 8 years ago by atagar

Description: modified (diff)
Keywords: controller added
Priority: normalminor

comment:2 Changed 8 years ago by gsathya

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.

comment:3 Changed 8 years ago 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('#'):
      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

comment:4 Changed 8 years ago by gsathya

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.

comment:5 Changed 7 years ago by atagar

Resolution: duplicate
Status: newclosed

Resolving in favor of #8251.

Note: See TracTickets for help on using tickets.