Add initial code
[ta/build-tools.git] / tools / script / read_build_config.py
1 #!/usr/bin/env python
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 import sys
17
18 from tools.buildconfig import BuildConfigParser
19
20
21 def main():
22     config = BuildConfigParser(sys.argv[1])
23     if len(sys.argv) == 3:
24         print(config.items(sys.argv[2]))
25     elif len(sys.argv) == 4:
26         print(config.get(sys.argv[2], sys.argv[3]))
27     else:
28         raise Exception('Invalid parameter count: {}'.format(len(sys.argv)))
29
30
31 if __name__ == "__main__":
32     main()