Repository navigation
Expand file tree
/
Copy pathschemasync.py
More file actions
51 lines (46 loc) · 1.55 KB
/
Copy pathschemasync.py
File metadata and controls
51 lines (46 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: UTF-8 -*-
"""
@author: hhyo
@license: Apache Licence
@file: schemasync.py
@time: 2019/03/05
"""
__author__ = 'hhyo'
from common.config import SysConfig
from sql.plugins.plugin import Plugin
class SchemaSync(Plugin):
def __init__(self):
self.path = SysConfig().get('schemasync')
self.required_args = []
self.disable_args = []
super(Plugin, self).__init__()
def generate_args2cmd(self, args, shell):
"""
转换请求参数为命令行
:param args:
:param shell:
:return:
"""
k_options = ['sync-auto-inc', 'sync-comments']
kv_options = ['tag', 'output-directory', 'log-directory']
v_options = ['source', 'target']
if shell:
cmd_args = self.path if self.path else ''
for name, value in args.items():
if name in k_options and value:
cmd_args += f' --{name}'
elif name in kv_options:
cmd_args += f' --{name}={value}'
elif name in v_options:
cmd_args += f' {value}'
else:
cmd_args = [self.path]
for name, value in args.items():
if name in k_options and value:
cmd_args.append(f'--{name}')
elif name in kv_options:
cmd_args.append(f'--{name}')
cmd_args.append(f'{value}')
elif name in ['source', 'target']:
cmd_args.append(f'{value}')
return cmd_args