Esempio n. 1
0
def readini(inifile):
    """ This function will read in data from a configureation file.
        Inputs
            inifile- The name of the configuration file.
        Outputs
            params - A dictionary with keys from INIOPTIONS that holds all of
                the plotting parameters.
    """
    if inifile is None:
        return

    config =configparser()
    config.read(inifile)
    params={i:None for i in INIOPTIONS}
    # Read in data from ini file
    for ip in config.options('params'):
        # get the original param name
        rname  = config.get('paramsnames',ip)
        # get the parameter and split it up
        params[rname] = config.get('params',ip)
        params[rname]=params[rname].split(" ")
        # If its a single object try to
        if len(params[rname])==1:
            params[rname]=params[rname][0]
            try:
                params[rname]=float(params[rname])
            except Exception:
                pass
        else:
            for a in range(len(params[rname])):
                try:
                    params[rname][a]=float(params[rname][a])
                except Exception:
                    pass

    # turn the time bounds to time stamps
    if not params['timebounds']is None:
        timelist = params['timebounds']
        params['timebounds']=str2posix(timelist)
    # which times will have names
    if params['TextList'] is None:
        params['TextList']=[]



    # change param height to a list of lists
    if not params['paramheight'] is None:
        l1 = params['paramheight'][::2]
        l2 = params['paramheight'][1::2]
        params['paramheight']=[[i,j] for i,j in zip(l1,l2)]
    if not params['paramlim'] is None:
        l1 = params['paramlim'][::2]
        l2 = params['paramlim'][1::2]
        params['paramlim']=[[i,j] for i,j in zip(l1,l2)]
    # Default for reinterp is false
    if params['reinterp']is None:
        params['reinterp']=False
    else:
        params['reinterp'] = params['reinterp'].lower()=='yes'
    return params
Esempio n. 2
0
def main(argv):
    root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

    if os.environ.get('tools_path'):
        root = os.environ['tools_path']
    venv = os.path.join(root, '.venv')
    if os.environ.get('venv'):
        venv = os.environ['venv']

    pip_requires = os.path.join(root, 'requirements.txt')
    test_requires = os.path.join(root, 'test-requirements.txt')
    py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
    setup_cfg = configparser.configparser()
    setup_cfg.read('setup.cfg')
    project = setup_cfg.get('metadata', 'name')

    install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
                                       py_version, project)
    options = install.parse_args(argv)
    install.check_python_version()
    install.check_dependencies()
    install.create_virtualenv(no_site_packages=options.no_site_packages)
    install.install_dependencies()
    install.post_process()
    print_help(project, venv, root)
Esempio n. 3
0
def main(argv):
    root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

    if os.environ.get('tools_path'):
        root = os.environ['tools_path']
    venv = os.path.join(root, '.venv')
    if os.environ.get('venv'):
        venv = os.environ['venv']

    pip_requires = os.path.join(root, 'requirements.txt')
    test_requires = os.path.join(root, 'test-requirements.txt')
    py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
    setup_cfg = configparser.configparser()
    setup_cfg.read('setup.cfg')
    project = setup_cfg.get('metadata', 'name')

    install = install_venv.InstallVenv(
        root, venv, pip_requires, test_requires, py_version, project)
    options = install.parse_args(argv)
    install.check_python_version()
    install.check_dependencies()
    install.create_virtualenv(no_site_packages=options.no_site_packages)
    install.install_dependencies()
    install.post_process()
    print_help(project, venv, root)
Esempio n. 4
0
def writeini(params,fname):
    """ This will write out a structured ini file that can be used by the PlotClass
        to fill its dictionary of parameters.
        Inputs
            params - A dictionary that holds the parameters for the PlotClass.
            fname - The name of the file it will be written out to.
    """
    with fname.open('w') as cfgfile:
        config = configparser(allow_no_value = True)

        config.add_section('params')
        config.add_section('paramsnames')
        for ip in INIOPTIONS:

            if not ip in params.keys():
                continue
            elif ip=='timebounds':
                config.set('params',ip,' '.join(posix2str(params[ip])))
            elif ip=='paramheight':
                temp= [item for sublist in params[ip] for item in sublist]
                data = ""
                for a in temp:
                    data += str(a)
                    data += " "
                config.set('params',ip,data)
            elif ip=='paramlim':
                temp= [item for sublist in params[ip] for item in sublist]
                data = ""
                for a in temp:
                    data += str(a)
                    data += " "
                config.set('params',ip,data)
            elif ip=='reinterp':
                if params[ip]:
                    data='Yes'
                else:
                    data='No'
                config.set('params',ip,data)
            elif type(params[ip]) in (sp.ndarray,list):
                data = ""
                for a in params[ip]:
                    data += str(a)
                    data += " "
                config.set('params',ip,data)
            else:
                config.set('params',ip,str(params[ip]))
            config.set('paramsnames',ip,ip)
        config.write(cfgfile)