[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Preserve structure of config file while saving



commit dd29415f27eb509ca496bc2159258a3a6b5d7774
Author: Sathyanarayanan Gunasekaran <gsathya.ceg@xxxxxxxxx>
Date:   Thu Feb 9 01:16:51 2012 +0530

    Preserve structure of config file while saving
    
    Previously the single line config entries were
    converted to a multi line structure and then
    saved. Now, the structure of the config file is
    preserved.
    
    Fixed by atagar
---
 stem/util/conf.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/stem/util/conf.py b/stem/util/conf.py
index b88dd10..6eac9a1 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -268,7 +268,9 @@ class Config():
     with open(self._path, 'w') as output_file:
       for entry_key in sorted(self.keys()):
         for entry_value in self.get_value(entry_key, multiple = True):
-          output_file.write('%s\n|%s\n' % (entry_key, entry_value.replace("\n", "\n|")))
+          # check for multi line entries
+          if "\n" in entry_value: entry_value = "\n|" + entry_value.replace("\n", "\n|")
+          output_file.write('%s %s\n' % (entry_key, entry_value))
                     
     self._contents_lock.release()
   



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits