diff options
author | xudan <xudan16@huawei.com> | 2019-11-03 09:11:00 -0500 |
---|---|---|
committer | xudan <xudan16@huawei.com> | 2019-11-04 22:51:14 -0500 |
commit | d20dd6a164c77ab9acbfb1d74ea39a991d942e43 (patch) | |
tree | e3757402dea58629926b0519302e82fb6027d1bc /dovetail/api/app/utils.py | |
parent | 01bca75cc4af1665918a04c2a9a8c36dfb473d77 (diff) |
Refact API module
Change-Id: Ifa01fcbb848d3218619c1f8e726f26476773ce2f
Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/api/app/utils.py')
-rw-r--r-- | dovetail/api/app/utils.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/dovetail/api/app/utils.py b/dovetail/api/app/utils.py index 1708dfb7..9f35ee03 100644 --- a/dovetail/api/app/utils.py +++ b/dovetail/api/app/utils.py @@ -2,20 +2,23 @@ import json import os -def write_env_file(envs, file_path): - file_dir = os.path.dirname(file_path) - if not os.path.exists(file_dir): - os.makedirs(file_dir) - with open(file_path, "w") as f: - for key, value in envs.items(): - f.write("export {}={}\n".format(key, value)) - return True +class Utils(object): + @staticmethod + def write_env_file(envs, file_path): + file_dir = os.path.dirname(file_path) + if not os.path.exists(file_dir): + os.makedirs(file_dir) + with open(file_path, "w") as f: + for key, value in envs.items(): + f.write("export {}={}\n".format(key, value)) + return True -def write_yaml_file(data, file_path): - file_dir = os.path.dirname(file_path) - if not os.path.exists(file_dir): - os.makedirs(file_dir) - with open(file_path, "w") as f: - f.write(json.dumps(data) + '\n') - return True + @staticmethod + def write_yaml_file(data, file_path): + file_dir = os.path.dirname(file_path) + if not os.path.exists(file_dir): + os.makedirs(file_dir) + with open(file_path, "w") as f: + f.write(json.dumps(data) + '\n') + return True |