Opened 7 years ago

Closed 7 years ago

#7654 closed enhancement (duplicate)

torrc parser in stem

Reported by: gsathya Owned by: atagar
Priority: Low Milestone:
Component: Core Tor/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...
https://gitweb.torproject.org/arm.git/blob/HEAD:/src/util/torConfig.py

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 7 years ago by atagar

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

comment:2 Changed 7 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.

https://gitweb.torproject.org/user/gsathya/stem.git/commitdiff/0b7c415642257faec9ec3212717a961eaf1ec8f6?hp=0d01ad60bb2a4ea2f0ac1f9626360d5db22858ea

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

comment:4 Changed 7 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.