[tor-commits] [nyx/master] Merge _strip_comments() into caller

atagar at torproject.org atagar at torproject.org
Sun Feb 14 02:55:49 UTC 2016


commit 80178f6e0504c719f30e1f12694a1a8dcfed4631
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Feb 6 13:29:25 2016 -0800

    Merge _strip_comments() into caller
    
    Merging another helper that doesn't add much.
---
 nyx/util/tor_config.py | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/nyx/util/tor_config.py b/nyx/util/tor_config.py
index ed8c88e..e8b82b3 100644
--- a/nyx/util/tor_config.py
+++ b/nyx/util/tor_config.py
@@ -103,7 +103,12 @@ def validate(contents):
 
   stripped_contents, multiline_buffer = [], ''
 
-  for line in _strip_comments(contents):
+  for line in contents:
+    if '#' in line:
+      line = line[:line.find('#')]
+
+    line = line.strip()
+
     if not line:
       stripped_contents.append('')
     else:
@@ -238,22 +243,3 @@ def _parse_conf_value(conf_arg):
           return str(int(val) * TIME_MULT[label]), ValueType.TIME
 
   return conf_arg, ValueType.UNRECOGNIZED
-
-
-def _strip_comments(contents):
-  """
-  Removes comments and extra whitespace from the given torrc contents.
-
-  Arguments:
-    contents - torrc contents
-  """
-
-  stripped_contents = []
-
-  for line in contents:
-    if line and '#' in line:
-      line = line[:line.find('#')]
-
-    stripped_contents.append(line.strip())
-
-  return stripped_contents





More information about the tor-commits mailing list