Commit | Line | Data |
---|---|---|
e5aa0be3 PP |
1 | # The MIT License (MIT) |
2 | # | |
4a90140d | 3 | # Copyright (c) 2015-2020 Philippe Proulx <pproulx@efficios.com> |
e5aa0be3 | 4 | # |
1378f213 PP |
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: | |
e5aa0be3 | 12 | # |
1378f213 PP |
13 | # The above copyright notice and this permission notice shall be |
14 | # included in all copies or substantial portions of the Software. | |
e5aa0be3 | 15 | # |
1378f213 PP |
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. | |
e5aa0be3 | 23 | |
7f4429f2 | 24 | from barectf import config_parse |
e5aa0be3 PP |
25 | |
26 | ||
9fb5657f | 27 | _ConfigParseError = config_parse._ConfigParseError |
e5aa0be3 PP |
28 | |
29 | ||
30 | class Config: | |
7f4429f2 PP |
31 | def __init__(self, metadata, prefix=None, options=None): |
32 | self._metadata = metadata | |
a1a610d4 | 33 | |
7f4429f2 PP |
34 | if prefix is None: |
35 | self._prefix = 'barectf_' | |
36 | else: | |
37 | self._prefix = prefix | |
e5aa0be3 | 38 | |
7f4429f2 PP |
39 | if options is None: |
40 | self._options = ConfigOptions() | |
41 | else: | |
42 | self._options = options | |
e5aa0be3 PP |
43 | |
44 | @property | |
45 | def metadata(self): | |
46 | return self._metadata | |
47 | ||
e5aa0be3 PP |
48 | @property |
49 | def prefix(self): | |
50 | return self._prefix | |
51 | ||
893854db PP |
52 | @property |
53 | def options(self): | |
54 | return self._options | |
55 | ||
893854db PP |
56 | |
57 | class ConfigOptions: | |
7f4429f2 | 58 | def __init__(self, gen_prefix_def=False, gen_default_stream_def=False): |
893854db PP |
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 | ||
893854db PP |
66 | @property |
67 | def gen_default_stream_def(self): | |
68 | return self._gen_default_stream_def | |
69 | ||
e5aa0be3 | 70 | |
7f4429f2 PP |
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) | |
e5aa0be3 | 74 | |
f58be68f | 75 | |
7f4429f2 PP |
76 | # deprecated |
77 | from_yaml_file = from_file |