未验证 提交 0ec12960 编写于 作者: C chenjian 提交者: GitHub

robust autofilling fd client (#1204)

上级 0975664e
...@@ -271,8 +271,10 @@ def create_app(args): # noqa: C901 ...@@ -271,8 +271,10 @@ def create_app(args): # noqa: C901
ensure_ascii=True).replace( ensure_ascii=True).replace(
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_server_addr = server_addr_match.group(0) default_server_addr = server_addr_match.group(0)
if '"value": ""' in default_server_addr:
cur_server_addr = default_server_addr.replace( cur_server_addr = default_server_addr.replace(
'"value": ""', '"value": "localhost"') '"value": ""', '"value": "localhost"')
else:
cur_server_addr = default_server_addr.replace( cur_server_addr = default_server_addr.replace(
'"value":""', '"value": "localhost"') '"value":""', '"value": "localhost"')
content = content.replace(default_server_addr, content = content.replace(default_server_addr,
...@@ -292,10 +294,14 @@ def create_app(args): # noqa: C901 ...@@ -292,10 +294,14 @@ def create_app(args): # noqa: C901
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_http_port = http_port_match.group(0) default_http_port = http_port_match.group(0)
if '"value": ""' in default_http_port:
cur_http_port = default_http_port.replace( cur_http_port = default_http_port.replace(
'"value": ""', '"value": "{}"'.format(http_port)) '"value": ""',
'"value": "{}"'.format(http_port))
else:
cur_http_port = default_http_port.replace( cur_http_port = default_http_port.replace(
'"value":""', '"value": "{}"'.format(http_port)) '"value":""',
'"value": "{}"'.format(http_port))
if http_port: if http_port:
content = content.replace(default_http_port, content = content.replace(default_http_port,
cur_http_port) cur_http_port)
...@@ -313,11 +319,14 @@ def create_app(args): # noqa: C901 ...@@ -313,11 +319,14 @@ def create_app(args): # noqa: C901
ensure_ascii=True).replace( ensure_ascii=True).replace(
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_metrics_port = metrics_port_match.group(0) default_metrics_port = metrics_port_match.group(0)
if '"value": ""' in default_metrics_port:
cur_metrics_port = default_metrics_port.replace( cur_metrics_port = default_metrics_port.replace(
'"value": ""', '"value": ""',
'"value": "{}"'.format(metrics_port)) '"value": "{}"'.format(metrics_port))
else:
cur_metrics_port = default_metrics_port.replace( cur_metrics_port = default_metrics_port.replace(
'"value":""', '"value": "{}"'.format(metrics_port)) '"value":""',
'"value": "{}"'.format(metrics_port))
if metrics_port: if metrics_port:
content = content.replace(default_metrics_port, content = content.replace(default_metrics_port,
cur_metrics_port) cur_metrics_port)
...@@ -335,10 +344,14 @@ def create_app(args): # noqa: C901 ...@@ -335,10 +344,14 @@ def create_app(args): # noqa: C901
ensure_ascii=True).replace( ensure_ascii=True).replace(
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_model_name = model_name_match.group(0) default_model_name = model_name_match.group(0)
if '"value": ""' in default_model_name:
cur_model_name = default_model_name.replace( cur_model_name = default_model_name.replace(
'"value": ""', '"value": "{}"'.format(model_name)) '"value": ""',
'"value": "{}"'.format(model_name))
else:
cur_model_name = default_model_name.replace( cur_model_name = default_model_name.replace(
'"value":""', '"value": "{}"'.format(model_name)) '"value":""',
'"value": "{}"'.format(model_name))
if model_name: if model_name:
content = content.replace(default_model_name, content = content.replace(default_model_name,
cur_model_name) cur_model_name)
...@@ -356,8 +369,10 @@ def create_app(args): # noqa: C901 ...@@ -356,8 +369,10 @@ def create_app(args): # noqa: C901
ensure_ascii=True).replace( ensure_ascii=True).replace(
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_model_version = model_version_match.group(0) default_model_version = model_version_match.group(0)
if '"value": ""' in default_model_version:
cur_model_version = default_model_version.replace( cur_model_version = default_model_version.replace(
'"value": ""', '"value": "{}"'.format('1')) '"value": ""', '"value": "{}"'.format('1'))
else:
cur_model_version = default_model_version.replace( cur_model_version = default_model_version.replace(
'"value":""', '"value": "{}"'.format('1')) '"value":""', '"value": "{}"'.format('1'))
content = content.replace(default_model_version, content = content.replace(default_model_version,
...@@ -393,8 +408,10 @@ def create_app(args): # noqa: C901 ...@@ -393,8 +408,10 @@ def create_app(args): # noqa: C901
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_server_addr = server_addr_match.group(0) default_server_addr = server_addr_match.group(0)
if '"value": ""' in default_server_addr:
cur_server_addr = default_server_addr.replace( cur_server_addr = default_server_addr.replace(
'"value": ""', '"value": "localhost"') '"value": ""', '"value": "localhost"')
else:
cur_server_addr = default_server_addr.replace( cur_server_addr = default_server_addr.replace(
'"value":""', '"value": "localhost"') '"value":""', '"value": "localhost"')
content = content.replace(default_server_addr, content = content.replace(default_server_addr,
...@@ -430,10 +447,14 @@ def create_app(args): # noqa: C901 ...@@ -430,10 +447,14 @@ def create_app(args): # noqa: C901
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_http_port = http_port_match.group(0) default_http_port = http_port_match.group(0)
if '"value": ""' in default_http_port:
cur_http_port = default_http_port.replace( cur_http_port = default_http_port.replace(
'"value": ""', '"value": "{}"'.format(http_port)) '"value": ""',
'"value": "{}"'.format(http_port))
else:
cur_http_port = default_http_port.replace( cur_http_port = default_http_port.replace(
'"value":""', '"value": "{}"'.format(http_port)) '"value":""',
'"value": "{}"'.format(http_port))
if http_port: if http_port:
content = content.replace(default_http_port, content = content.replace(default_http_port,
cur_http_port) cur_http_port)
...@@ -467,11 +488,14 @@ def create_app(args): # noqa: C901 ...@@ -467,11 +488,14 @@ def create_app(args): # noqa: C901
ensure_ascii=False).replace( ensure_ascii=False).replace(
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_metrics_port = metrics_port_match.group(0) default_metrics_port = metrics_port_match.group(0)
if '"value": ""' in default_metrics_port:
cur_metrics_port = default_metrics_port.replace( cur_metrics_port = default_metrics_port.replace(
'"value": ""', '"value": ""',
'"value": "{}"'.format(metrics_port)) '"value": "{}"'.format(metrics_port))
else:
cur_metrics_port = default_metrics_port.replace( cur_metrics_port = default_metrics_port.replace(
'"value":""', '"value": "{}"'.format(metrics_port)) '"value":""',
'"value": "{}"'.format(metrics_port))
if metrics_port: if metrics_port:
content = content.replace(default_metrics_port, content = content.replace(default_metrics_port,
cur_metrics_port) cur_metrics_port)
...@@ -503,10 +527,14 @@ def create_app(args): # noqa: C901 ...@@ -503,10 +527,14 @@ def create_app(args): # noqa: C901
ensure_ascii=False).replace( ensure_ascii=False).replace(
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_model_name = model_name_match.group(0) default_model_name = model_name_match.group(0)
if '"value": ""' in default_model_name:
cur_model_name = default_model_name.replace( cur_model_name = default_model_name.replace(
'"value": ""', '"value": "{}"'.format(model_name)) '"value": ""',
'"value": "{}"'.format(model_name))
else:
cur_model_name = default_model_name.replace( cur_model_name = default_model_name.replace(
'"value":""', '"value": "{}"'.format(model_name)) '"value":""',
'"value": "{}"'.format(model_name))
if model_name: if model_name:
content = content.replace(default_model_name, content = content.replace(default_model_name,
cur_model_name) cur_model_name)
...@@ -539,8 +567,10 @@ def create_app(args): # noqa: C901 ...@@ -539,8 +567,10 @@ def create_app(args): # noqa: C901
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_model_version = model_version_match.group(0) default_model_version = model_version_match.group(0)
if '"value": ""' in default_model_version:
cur_model_version = default_model_version.replace( cur_model_version = default_model_version.replace(
'"value": ""', '"value": "{}"'.format('1')) '"value": ""', '"value": "{}"'.format('1'))
else:
cur_model_version = default_model_version.replace( cur_model_version = default_model_version.replace(
'"value":""', '"value": "{}"'.format('1')) '"value":""', '"value": "{}"'.format('1'))
content = content.replace(default_model_version, content = content.replace(default_model_version,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册