summaryrefslogtreecommitdiff
path: root/lib/git/config.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-12-08 20:01:17 +0100
committerSebastian Thiel <byronimo@gmail.com>2009-12-08 20:01:17 +0100
commit6a417f4cf2df39704aa4c869e88d14e9806894a7 (patch)
treed11d42889010b43e980f26b939a8368fb861f07f /lib/git/config.py
parentc76a8c5499d22b9c0b4c56f03b671033eb9f9bdd (diff)
downloadgitpython-6a417f4cf2df39704aa4c869e88d14e9806894a7.tar.gz
config.set_value: added more convenient set_value method to ConfigReader
Diffstat (limited to 'lib/git/config.py')
-rw-r--r--lib/git/config.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/git/config.py b/lib/git/config.py
index 1739e786..e8bdfc75 100644
--- a/lib/git/config.py
+++ b/lib/git/config.py
@@ -387,3 +387,23 @@ class GitConfigParser(cp.RawConfigParser, LockFile):
raise TypeError( "Invalid value type: only int, long, float and str are allowed", valuestr )
return valuestr
+
+ @_needs_values
+ @_set_dirty_and_flush_changes
+ def set_value(self, section, option, value):
+ """Sets the given option in section to the given value.
+ It will create the section if required, and will not throw as opposed to the default
+ ConfigParser 'set' method.
+
+ ``section``
+ Name of the section in which the option resides or should reside
+
+ ``option``
+ Name of the options whose value to set
+
+ ``value``
+ Value to set the option to. It must be a string or convertible to a string
+ """
+ if not self.has_section(section):
+ self.add_section(section)
+ self.set(section, option, str(value))