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

robust autofilling fd client (#1204)

上级 0975664e
...@@ -271,10 +271,12 @@ def create_app(args): # noqa: C901 ...@@ -271,10 +271,12 @@ 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)
cur_server_addr = default_server_addr.replace( if '"value": ""' in default_server_addr:
'"value": ""', '"value": "localhost"') 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(
'"value":""', '"value": "localhost"')
content = content.replace(default_server_addr, content = content.replace(default_server_addr,
cur_server_addr) cur_server_addr)
http_port_match = re.search( http_port_match = re.search(
...@@ -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)
cur_http_port = default_http_port.replace( if '"value": ""' in default_http_port:
'"value": ""', '"value": "{}"'.format(http_port)) cur_http_port = default_http_port.replace(
cur_http_port = default_http_port.replace( '"value": ""',
'"value":""', '"value": "{}"'.format(http_port)) '"value": "{}"'.format(http_port))
else:
cur_http_port = default_http_port.replace(
'"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)
cur_metrics_port = default_metrics_port.replace( if '"value": ""' in default_metrics_port:
'"value": ""', cur_metrics_port = default_metrics_port.replace(
'"value": "{}"'.format(metrics_port)) '"value": ""',
cur_metrics_port = default_metrics_port.replace( '"value": "{}"'.format(metrics_port))
'"value":""', '"value": "{}"'.format(metrics_port)) else:
cur_metrics_port = default_metrics_port.replace(
'"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)
cur_model_name = default_model_name.replace( if '"value": ""' in default_model_name:
'"value": ""', '"value": "{}"'.format(model_name)) cur_model_name = default_model_name.replace(
cur_model_name = default_model_name.replace( '"value": ""',
'"value":""', '"value": "{}"'.format(model_name)) '"value": "{}"'.format(model_name))
else:
cur_model_name = default_model_name.replace(
'"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,10 +369,12 @@ def create_app(args): # noqa: C901 ...@@ -356,10 +369,12 @@ 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)
cur_model_version = default_model_version.replace( if '"value": ""' in default_model_version:
'"value": ""', '"value": "{}"'.format('1')) 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(
'"value":""', '"value": "{}"'.format('1'))
content = content.replace(default_model_version, content = content.replace(default_model_version,
cur_model_version) cur_model_version)
...@@ -393,10 +408,12 @@ def create_app(args): # noqa: C901 ...@@ -393,10 +408,12 @@ def create_app(args): # noqa: C901
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_server_addr = server_addr_match.group(0) default_server_addr = server_addr_match.group(0)
cur_server_addr = default_server_addr.replace( if '"value": ""' in default_server_addr:
'"value": ""', '"value": "localhost"') 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(
'"value":""', '"value": "localhost"')
content = content.replace(default_server_addr, content = content.replace(default_server_addr,
cur_server_addr) cur_server_addr)
http_port_match = re.search( http_port_match = re.search(
...@@ -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)
cur_http_port = default_http_port.replace( if '"value": ""' in default_http_port:
'"value": ""', '"value": "{}"'.format(http_port)) cur_http_port = default_http_port.replace(
cur_http_port = default_http_port.replace( '"value": ""',
'"value":""', '"value": "{}"'.format(http_port)) '"value": "{}"'.format(http_port))
else:
cur_http_port = default_http_port.replace(
'"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)
cur_metrics_port = default_metrics_port.replace( if '"value": ""' in default_metrics_port:
'"value": ""', cur_metrics_port = default_metrics_port.replace(
'"value": "{}"'.format(metrics_port)) '"value": ""',
cur_metrics_port = default_metrics_port.replace( '"value": "{}"'.format(metrics_port))
'"value":""', '"value": "{}"'.format(metrics_port)) else:
cur_metrics_port = default_metrics_port.replace(
'"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)
cur_model_name = default_model_name.replace( if '"value": ""' in default_model_name:
'"value": ""', '"value": "{}"'.format(model_name)) cur_model_name = default_model_name.replace(
cur_model_name = default_model_name.replace( '"value": ""',
'"value":""', '"value": "{}"'.format(model_name)) '"value": "{}"'.format(model_name))
else:
cur_model_name = default_model_name.replace(
'"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,10 +567,12 @@ def create_app(args): # noqa: C901 ...@@ -539,10 +567,12 @@ def create_app(args): # noqa: C901
'\\', '\\\\')), content) '\\', '\\\\')), content)
default_model_version = model_version_match.group(0) default_model_version = model_version_match.group(0)
cur_model_version = default_model_version.replace( if '"value": ""' in default_model_version:
'"value": ""', '"value": "{}"'.format('1')) 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(
'"value":""', '"value": "{}"'.format('1'))
content = content.replace(default_model_version, content = content.replace(default_model_version,
cur_model_version) cur_model_version)
except Exception: except Exception:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册