Example #1
0
 def setUp(self):
     project_name = 'Test project'
     project_dir = './'
     prj = OQtProject(project_name, project_dir)
     model_id = 'model01'
     model = OQtModel(model_id=model_id, name='Test model')
     prj.add_model(model)
Example #2
0
def project_create(argv):
    """
    This creates a new `oqmbt` project

    :parameter argv:
        A list. The first argument contains the path to the folder where the
        project will be created. The second parameter is the folder (this
        overrides the `directory` parameter in the `project` section of the
        .ini file
    """
    ini_filename = argv[0]
    print('Reading project information from: \n{:s}'.format(ini_filename))
    assert os.path.exists(ini_filename)
    #
    # reading the .ini file
    config = ConfigParser(dict_type=AttrDict)
    config.read(ini_filename)
    #
    # set project dir and name
    if len(argv) > 1:
        project_dir = argv[1]
        config._sections.project.directory = project_dir
    else:
        project_dir = os.path.abspath(config._sections.project.directory)
    project_name = config._sections.project.name
    #
    # info
    print('Project directory : {:s}'.format((project_dir)))
    print('Project name      : {:s}'.format((project_name)))
    #
    # create a clean project directory
    delete_and_create_project_dir(project_dir)
    #
    # create the project
    prj = OQtProject(project_name, project_dir)
    # MN: 'project_filename' assigned but never used
    project_filename = os.path.join(project_dir, prj._get_filename())
    #
    # create default files
    create_default_files(prj, project_dir)
    #
    # add standard subfolders
    add_subfolders(project_dir)
    #
    # load information for the various models
    for key in config._sections.keys():
        #
        # search for sections containing model information
        if re.search('^model', key):
            model = load_model_info(config, key)
            prj.add_model(model)
    #
    # save the project
    prj.save()