Total Complexity | 7 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | #!/usr/bin/env python |
||
25 | class Config(dict): |
||
26 | def __init__(self, filename): |
||
27 | with open(self.find(filename)) as file: |
||
28 | self.merge(json.load(file)) |
||
29 | |||
30 | def merge(self, data): |
||
31 | merge_dict(self, data) |
||
32 | |||
33 | def find(self, filename): |
||
34 | if os.path.isfile(filename): |
||
35 | return filename |
||
36 | |||
37 | command = sys.argv[0] |
||
38 | if '/' != command[0]: |
||
39 | command = os.path.normpath(os.path.join(os.getcwd(), command)) |
||
40 | path = os.path.join(os.path.dirname(os.path.dirname(command)), 'etc', filename) |
||
41 | if os.path.isfile(path): |
||
42 | return path |
||
43 | |||
44 | return os.path.join('/etc/heppy', filename) |
||
45 |