Skip to content
Snippets Groups Projects
Commit 062aa0b7 authored by ale's avatar ale
Browse files

do not log since logging is not setup yet anyway; unquote configuration values

parent 999c4941
No related branches found
No related tags found
No related merge requests found
import hashlib import hashlib
import logging
import os import os
NESTING = 2 NESTING = 2
log = logging.getLogger(__name__)
def generate_path(base_dir, sha1): def generate_path(base_dir, sha1):
dir_parts = [base_dir] dir_parts = [base_dir]
...@@ -31,8 +28,14 @@ class SyntaxError(Exception): ...@@ -31,8 +28,14 @@ class SyntaxError(Exception):
pass pass
def _unquote(s):
for qchar in ('"', '\''):
if s.startswith(qchar) and s.endswith(qchar):
return s.strip(qchar)
return s
def read_config_defaults(parser, path): def read_config_defaults(parser, path):
log.debug('reading config from %s' % path)
if not os.path.exists(path): if not os.path.exists(path):
return return
with open(path, 'r') as fd: with open(path, 'r') as fd:
...@@ -44,5 +47,4 @@ def read_config_defaults(parser, path): ...@@ -44,5 +47,4 @@ def read_config_defaults(parser, path):
raise SyntaxError('%s, line %d: Syntax Error' % ( raise SyntaxError('%s, line %d: Syntax Error' % (
path, 1 + linenum)) path, 1 + linenum))
var, value = map(lambda x: x.strip(), line.split('=', 1)) var, value = map(lambda x: x.strip(), line.split('=', 1))
log.debug('config: %s = "%s"' % (var, value)) parser.set_default(var, _unquote(value))
parser.set_default(var, value)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment