d9903098071e22a206e507bb3ec3c1888024aab2
[deliverable/barectf.git] / barectf / config.py
1 # The MIT License (MIT)
2 #
3 # Copyright (c) 2015-2020 Philippe Proulx <pproulx@efficios.com>
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 from barectf import config_parse
25
26
27 _ConfigParseError = config_parse._ConfigParseError
28
29
30 class Config:
31 def __init__(self, metadata, prefix=None, options=None):
32 self._metadata = metadata
33
34 if prefix is None:
35 self._prefix = 'barectf_'
36 else:
37 self._prefix = prefix
38
39 if options is None:
40 self._options = ConfigOptions()
41 else:
42 self._options = options
43
44 @property
45 def metadata(self):
46 return self._metadata
47
48 @property
49 def prefix(self):
50 return self._prefix
51
52 @property
53 def options(self):
54 return self._options
55
56
57 class ConfigOptions:
58 def __init__(self, gen_prefix_def=False, gen_default_stream_def=False):
59 self._gen_prefix_def = False
60 self._gen_default_stream_def = False
61
62 @property
63 def gen_prefix_def(self):
64 return self._gen_prefix_def
65
66 @property
67 def gen_default_stream_def(self):
68 return self._gen_default_stream_def
69
70
71 def from_file(path, include_dirs, ignore_include_not_found, dump_config):
72 return config_parse._from_file(path, include_dirs, ignore_include_not_found,
73 dump_config)
74
75
76 # deprecated
77 from_yaml_file = from_file
This page took 0.029759 seconds and 3 git commands to generate.