[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Add stem.util.conf.save()
commit 451e13eb9552ab448072b863b180a338a4baeb24
Author: Sathyanarayanan Gunasekaran <gsathya.ceg@xxxxxxxxx>
Date: Sun Jan 15 23:16:06 2012 +0530
Add stem.util.conf.save()
This saves all the contents in the config file.
It overwrites the contents of the original
config file. The comments of the original file
will be lost.
---
stem/util/conf.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/stem/util/conf.py b/stem/util/conf.py
index c226f40..0c98206 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -439,3 +439,11 @@ class Config():
return default
else: return [int(val) for val in conf_comp]
+ def save(self):
+ self._contents_lock.acquire()
+
+ with open(path, 'w') as f:
+ for entry in self.keys():
+ f.write('%s %s\n' % (entry, self.get(entry)))
+
+ self._contents_lock.release()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits