mirror of https://gitlab.com/ita1024/waf.git
Utils: remove str_to_dict
This commit is contained in:
parent
cc67d628c1
commit
24cc97f42e
|
@ -378,33 +378,6 @@ def to_list(sth):
|
|||
else:
|
||||
return sth
|
||||
|
||||
re_nl = re.compile('\r*\n', re.M)
|
||||
def str_to_dict(txt):
|
||||
"""
|
||||
Parse a string with key = value pairs into a dictionary::
|
||||
|
||||
from waflib import Utils
|
||||
x = Utils.str_to_dict('''
|
||||
a = 1
|
||||
b = test
|
||||
''')
|
||||
|
||||
:type s: string
|
||||
:param s: String to parse
|
||||
:rtype: dict
|
||||
:return: Dictionary containing parsed key-value pairs
|
||||
"""
|
||||
tbl = {}
|
||||
|
||||
lines = re_nl.split(txt)
|
||||
for x in lines:
|
||||
x = x.strip()
|
||||
if not x or x.startswith('#') or x.find('=') < 0:
|
||||
continue
|
||||
tmp = x.split('=')
|
||||
tbl[tmp[0].strip()] = '='.join(tmp[1:]).strip()
|
||||
return tbl
|
||||
|
||||
def split_path(path):
|
||||
return path.split('/')
|
||||
|
||||
|
|
Loading…
Reference in New Issue