[projects/git-slug: 145/170] Unquote values read from config file

glen glen at pld-linux.org
Mon Sep 21 21:51:00 CEST 2015


commit fd0ebcdab8f38f17fd0f7b8e9b47f081bdb52ce1
Author: Kacper Kornet <draenog at pld-linux.org>
Date:   Wed Jul 25 05:55:41 2012 +0100

    Unquote values read from config file
    
    Try to reproduce the behaviour of git-config which removes '"' when
    present both at the beginning and end of the string. However in
    difference to git-config the error is not thrown up when only leading or
    trailing '"' is found.

 slug.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/slug.py b/slug.py
index 0f4f963..959ff18 100755
--- a/slug.py
+++ b/slug.py
@@ -18,6 +18,11 @@ from git_slug.gitconst import GITLOGIN, GITSERVER, GIT_REPO, GIT_REPO_PUSH, REMO
 from git_slug.gitrepo import GitRepo, GitRepoError
 from git_slug.refsdata import GitArchiveRefsData, NoMatchedRepos, RemoteRefsError
 
+class UnquoteConfig(configparser.ConfigParser):
+    def get(self, section, option, **kwargs):
+        value = super().get(section, option, **kwargs)
+        return value.strip('"')
+
 class DelAppend(argparse._AppendAction):
     def __call__(self, parser, namespace, values, option_string=None):
         item = copy.copy(getattr(namespace, self.dest, None)) if getattr(namespace, self.dest, None) is not None else []
@@ -47,7 +52,7 @@ class ThreadFetch(threading.Thread):
             self.queue.task_done()
 
 def readconfig(path):
-    config = configparser.ConfigParser(delimiters='=', interpolation=None, strict=False)
+    config = UnquoteConfig(delimiters='=', interpolation=None, strict=False)
     config.read(path)
     optionslist = {}
     for option in ('newpkgs', 'prune'):
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5



More information about the pld-cvs-commit mailing list