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
|
import sys, sqlite3, os, inspect, json, yaml
from os.path import expanduser
from collections import OrderedDict
from func_aux import checkFileExist
class LibYaml:
def __init__(self, directory=expanduser("~/.betcon/config.yml")):
self.directory = directory
checkFileExist(expanduser("~/.betcon"))
self.config = self.load()
self.stake = self.config["stake"]
self.interface = self.config["interface"]
def load(self):
if not os.path.exists(self.directory):
self.initConfig()
stream = open(self.directory, 'r')
config = yaml.load(stream)
stream.close()
return config
def initConfig(self):
data = {'stake': {'percentage': 1.0, 'stake': 0, 'type': 1}, 'interface': {'coin': '€', 'bookieCountry': 'N'}}
stream = open(self.directory, 'w')
yaml.dump(data, stream, default_flow_style=False)
stream.close()
def save(self):
stream = open(self.directory, 'w')
yaml.dump(self.config, stream, default_flow_style=False)
stream.close()
|