OpenCores
URL https://opencores.org/ocsvn/radiohdl/radiohdl/trunk

Subversion Repositories radiohdl

[/] [radiohdl/] [trunk/] [base/] [config_variable.py] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
#!/usr/bin/env python
2
###############################################################################
3
#
4
# Copyright (C) 2018
5
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
6
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
7
#
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
#
21
# $Id: config_variable.py 18844 2018-08-29 12:41:53Z overeem $
22
#
23
###############################################################################
24
import sys
25
import os
26
from os.path import expandvars, dirname, basename
27
from argparse import ArgumentParser
28
from configfile import ConfigFile
29
 
30
if __name__ == '__main__':
31
    # setup parser and parse the arguments.
32
    argparser = ArgumentParser(description='Options and arguments for showing hdl_config keys values')
33
    argparser.add_argument('configfile', help="Filename like 'hdl_buildset_<boardtype>.cfg'")
34
    argparser.add_argument('keyname',    help="Name of the key to show the value of.")
35
    args = argparser.parse_args()
36
 
37
    # resolve full name of configfile and force it to be explicit absolute or relative.
38
    full_configfile_name = expandvars(args.configfile)
39
    if full_configfile_name[0] != '/':
40
        full_configfile_name = "./" + full_configfile_name
41
    # read the file
42
    cfg_info = ConfigFile(full_configfile_name)
43
    cfg_info.resolve_key_references()
44
 
45
    print "{}\n".format(os.path.expandvars(cfg_info.get_value(args.keyname, must_exist=True)))
46
 

powered by: WebSVN 2.1.0

© copyright 1999-2019 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.