U 配置中心文本配置解析支持注释

pull/220/head
vapao 2020-09-14 17:29:16 +08:00
parent ff55d6cf8a
commit 9501cd1ae5
1 changed files with 6 additions and 5 deletions

View File

@ -223,7 +223,8 @@ def parse_text(request):
data = {}
for line in form.pop('data').split('\n'):
line = line.strip()
if line:
if not line or line[0] in ('#', ';'):
continue
fields = line.split('=', 1)
if len(fields) != 2 or fields[0].strip() == '':
return json_response(error=f'解析配置{line!r}失败,确认其遵循 key = value 格式')