Beispiel #1
0
def _xdsm_cmd(options):
    """
    Process command line args and call xdsm on the specified file.

    Parameters
    ----------
    options : argparse Namespace
        Command line options.
    """
    filename = options.file[0]

    kwargs = {}
    for name in [
            'box_stacking', 'box_width', 'box_lines', 'numbered_comps',
            'number_alignment'
    ]:
        val = getattr(options, name)
        if val is not None:
            kwargs[name] = val

    if filename.endswith('.py'):
        # the file is a python script, run as a post_setup hook
        def _xdsm(prob):
            write_xdsm(prob,
                       filename=options.outfile,
                       model_path=options.model_path,
                       recurse=options.recurse,
                       include_external_outputs=not options.no_extern_outputs,
                       out_format=options.format,
                       include_solver=options.include_solver,
                       subs=_CHAR_SUBS,
                       show_browser=not options.no_browser,
                       show_parallel=not options.no_parallel,
                       add_process_conns=not options.no_process_conns,
                       output_side=options.output_side,
                       legend=options.legend,
                       class_names=options.class_names,
                       **kwargs)
            exit()

        options.func = lambda options: _xdsm

        _post_setup_exec(options)
    else:
        # assume the file is a recording, run standalone
        write_xdsm(filename,
                   filename=options.outfile,
                   model_path=options.model_path,
                   recurse=options.recurse,
                   include_external_outputs=not options.no_extern_outputs,
                   out_format=options.format,
                   include_solver=options.include_solver,
                   subs=_CHAR_SUBS,
                   show_browser=not options.no_browser,
                   show_parallel=not options.no_parallel,
                   add_process_conns=not options.no_process_conns,
                   output_side=options.output_side,
                   **kwargs)
Beispiel #2
0
 def _xdsm(prob):
     write_xdsm(prob, filename=options.outfile, model_path=options.model_path,
                recurse=options.recurse,
                include_external_outputs=not options.no_extern_outputs,
                out_format=options.format,
                include_solver=options.include_solver, subs=_CHAR_SUBS,
                show_browser=not options.no_browser, show_parallel=not options.no_parallel,
                add_process_conns=not options.no_process_conns,
                output_side=options.output_side,
                legend=options.legend,
                class_names=options.class_names,
                **kwargs)
     exit()
Beispiel #3
0
def _xdsm_cmd(options, user_args):
    """
    Process command line args and call xdsm on the specified file.

    Parameters
    ----------
    options : argparse Namespace
        Command line options.
    user_args : list of str
        Command line options after '--' (if any).  Passed to user script.
    """
    filename = _to_filename(options.file[0])

    kwargs = {}
    for name in [
            'box_stacking', 'box_width', 'box_lines', 'numbered_comps',
            'number_alignment'
    ]:
        val = getattr(options, name)
        if val is not None:
            kwargs[name] = val

    if filename.endswith('.py'):
        # the file is a python script, run as a post_setup hook
        def _xdsm(prob):
            write_xdsm(prob,
                       filename=options.outfile,
                       model_path=options.model_path,
                       recurse=options.recurse,
                       include_external_outputs=not options.no_extern_outputs,
                       out_format=options.format,
                       include_solver=options.include_solver,
                       subs=_CHAR_SUBS,
                       show_browser=not options.no_browser,
                       show_parallel=not options.no_parallel,
                       add_process_conns=not options.no_process_conns,
                       output_side=options.output_side,
                       legend=options.legend,
                       class_names=options.class_names,
                       equations=options.equations,
                       **kwargs)
            exit()

        hooks._register_hook('setup', 'Problem', post=_xdsm)

        _load_and_exec(options.file[0], user_args)
    else:
        # assume the file is a recording, run standalone
        write_xdsm(filename,
                   filename=options.outfile,
                   model_path=options.model_path,
                   recurse=options.recurse,
                   include_external_outputs=not options.no_extern_outputs,
                   out_format=options.format,
                   include_solver=options.include_solver,
                   subs=_CHAR_SUBS,
                   show_browser=not options.no_browser,
                   show_parallel=not options.no_parallel,
                   add_process_conns=not options.no_process_conns,
                   output_side=options.output_side,
                   legend=options.legend,
                   class_names=options.class_names,
                   equations=options.equations,
                   **kwargs)