case sensitive config parser
This commit is contained in:
parent
6c2473e2da
commit
d6e4cdb45a
2 changed files with 21 additions and 15 deletions
|
@ -44,11 +44,11 @@ defaults = {
|
||||||
'php': {
|
'php': {
|
||||||
'post_max_size': '32G',
|
'post_max_size': '32G',
|
||||||
'www.conf': {
|
'www.conf': {
|
||||||
'env[hostname]': '$HOSTNAME',
|
'env[HOSTNAME]': '$HOSTNAME',
|
||||||
'env[path]': '/usr/local/bin:/usr/bin:/bin',
|
'env[PATH]': '/usr/local/bin:/usr/bin:/bin',
|
||||||
'env[tmp]': '/tmp',
|
'env[TMP]': '/tmp',
|
||||||
'env[tmpdir]': '/tmp',
|
'env[TMPDIR]': '/tmp',
|
||||||
'env[temp]': '/tmp',
|
'env[TEMP]': '/tmp',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'postgresql': {
|
'postgresql': {
|
||||||
|
|
26
libs/ini.py
26
libs/ini.py
|
@ -1,8 +1,18 @@
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
class Writable():
|
||||||
|
data = ''
|
||||||
|
def write(self, line):
|
||||||
|
self.data += line
|
||||||
|
|
||||||
|
class CaseSensitiveConfigParser(ConfigParser):
|
||||||
|
# dont make keys lowercase
|
||||||
|
def optionxform(self, value):
|
||||||
|
return value
|
||||||
|
|
||||||
def parse(text):
|
def parse(text):
|
||||||
config = ConfigParser()
|
config = CaseSensitiveConfigParser()
|
||||||
config.read_string(text)
|
config.read_string(text)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -10,17 +20,13 @@ def parse(text):
|
||||||
for section in config.sections()
|
for section in config.sections()
|
||||||
}
|
}
|
||||||
|
|
||||||
class Writable():
|
|
||||||
data = ''
|
|
||||||
|
|
||||||
def write(self, line):
|
|
||||||
self.data += line
|
|
||||||
|
|
||||||
def dumps(dict):
|
def dumps(dict):
|
||||||
config = ConfigParser()
|
|
||||||
sorted_dict = json.loads(json.dumps(dict, sort_keys=True))
|
sorted_dict = json.loads(json.dumps(dict, sort_keys=True))
|
||||||
config.read_dict(sorted_dict)
|
|
||||||
|
parser = CaseSensitiveConfigParser()
|
||||||
|
parser.read_dict(sorted_dict)
|
||||||
|
|
||||||
writable = Writable()
|
writable = Writable()
|
||||||
config.write(writable)
|
parser.write(writable)
|
||||||
|
|
||||||
return writable.data
|
return writable.data
|
||||||
|
|
Loading…
Reference in a new issue