-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
46 lines (41 loc) · 1.22 KB
/
settings.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#@created: 06.09.2011
#@author: Aleksey Komissarov
#@contact: [email protected]
"""
Trseeker settings loader.
"""
import os
import yaml
import platform
SETTINGS_FILENAME = "settings.yaml"
NGRAM_LENGTH = 23
NGRAM_N = 100000000
def load_settings():
""" Load settings from yaml file.
@return settings
"""
file_name = os.path.abspath(__file__)
settings_file = os.path.join(os.path.split(file_name)[0],
SETTINGS_FILENAME)
with open(settings_file) as fh:
settings = yaml.load(fh, Loader=yaml.FullLoader)
myos = platform.system()
if myos == "Windows":
settings["trseeker"]["os"] = "WIN"
elif myos == "Darwin":
settings["trseeker"]["os"] = "OSX"
else:
settings["trseeker"]["os"] = "NIX"
return settings
def save_settings(settings):
""" Save settings to yaml file.
@param settings: trseeker settings
"""
file_name = os.path.abspath(__file__)
settings_file = os.path.join(os.path.split(file_name)[0],
SETTINGS_FILENAME)
with open(settings_file, "w") as fh:
yaml.dump(fh, settings)