Ejemplo n.º 1
0
 def test_get_parser(self):
     parser = main.get_parser()
     args = inspect.getfullargspec(main.make_plot)[0]
     for arg in args:
         self.assertIn(arg,
                       parser.unfinished_arguments,
                       msg='Missing ' + arg)
Ejemplo n.º 2
0
def get_parser(create=True):
    """Return a parser to make that can be used to make plots or open files
    from the command line

    Returns
    -------
    psyplot.parser.FuncArgParser
        The :class:`argparse.ArgumentParser` instance

    See Also
    --------
    psyplot.main.get_parser
    psyplot.parser.FuncArgParser
    psyplot.main.main"""
    from psyplot.__main__ import get_parser
    parser = get_parser(create=False)

    parser.setup_args(start_app)

    gui_grp = parser.add_argument_group(
        'Gui options',
        'Options specific to the graphical user interface')

    parser.update_arg(
        'backend', short='b', const=None, nargs='?', metavar='backend',
        help="""
        The backend to use. By default, the ``'gui.backend'`` key in the
        :attr:`psyplot_gui.rcParams` dictionary is used. If used without
        options, the default matplotlib backend is used.""", group=gui_grp)

    parser.update_arg('new_instance', short='ni', group=gui_grp)

    parser.update_arg('rc_gui_file', short='rc-gui', group=gui_grp)
    parser.pop_key('rc_gui_file', 'metavar')
    parser.update_arg('include_plugins', short='inc', group=gui_grp,
                      default=rcParams['plugins.include'])
    parser.append2help('include_plugins', '. Default: %(default)s')
    parser.update_arg('exclude_plugins', short='exc', group=gui_grp,
                      default=rcParams['plugins.exclude'])
    parser.append2help('exclude_plugins', '. Default: %(default)s')

    parser.update_arg('offline', group=gui_grp)
    parser.update_arg('pwd', group=gui_grp)
    parser.update_arg('script', short='s', group=gui_grp)
    parser.update_arg('command', short='c', group=gui_grp)
    parser.pop_key('offline', 'short')

    parser.pop_arg('exec_')
    parser.pop_arg('callback')

    if psyplot.__version__ < '1.0':
        parser.set_main(start_app)

    parser.epilog += """

If you omit the ``'-o'`` option, the file is opened in the graphical user
interface and if you run::

    $ psyplot -pwd .

It will switch the directory of the already running GUI (if existent) to the
current working directory in your terminal. Additionally,::

    $ psyplot -s myscript.py

will run the file ``'myscript.py'`` in the GUI and::

    $ psyplot -c 'print("Hello World!")'

will execute ``print("Hello World")`` in the GUI. The output, of the `-s` and
`-c` options, will, however, be shown in the terminal."""

    if create:
        parser.create_arguments()

    return parser
Ejemplo n.º 3
0
def get_parser(create=True):
    """Return a parser to make that can be used to make plots or open files
    from the command line

    Returns
    -------
    psyplot.parser.FuncArgParser
        The :class:`argparse.ArgumentParser` instance

    See Also
    --------
    psyplot.main.get_parser
    psyplot.parser.FuncArgParser
    psyplot.main.main"""
    from psyplot.__main__ import get_parser
    parser = get_parser(create=False)

    parser.setup_args(start_app)

    gui_grp = parser.add_argument_group(
        'Gui options',
        'Options specific to the graphical user interface')

    parser.update_arg(
        'backend', short='b', const=None, nargs='?', metavar='backend',
        help="""
        The backend to use. By default, the ``'gui.backend'`` key in the
        :attr:`~psyplot_gui.config.rcsetup.rcParams` dictionary is used. If
        used without options, the default matplotlib backend is used.""",
        group=gui_grp)

    parser.update_arg('new_instance', short='ni', group=gui_grp)

    parser.update_arg('rc_gui_file', short='rc-gui', group=gui_grp)
    parser.pop_key('rc_gui_file', 'metavar')
    parser.update_arg('include_plugins', short='inc', group=gui_grp,
                      default=rcParams['plugins.include'])
    parser.append2help('include_plugins', '. Default: %(default)s')
    parser.update_arg('exclude_plugins', short='exc', group=gui_grp,
                      default=rcParams['plugins.exclude'])
    parser.append2help('exclude_plugins', '. Default: %(default)s')

    parser.update_arg('offline', group=gui_grp)
    parser.update_arg('pwd', group=gui_grp)
    parser.update_arg('script', short='s', group=gui_grp)
    parser.update_arg('command', short='c', group=gui_grp)

    parser.update_arg('opengl_implementation', group=gui_grp, short='opengl',
                      choices=['software', 'desktop', 'gles', 'automatic'])

    # add an action to display the GUI plugins
    info_grp = parser.unfinished_arguments['list_plugins'].get('group')
    parser.update_arg(
        'list_gui_plugins', short='lgp', long='list-gui-plugins',
        action=ListGuiPluginsAction, if_existent=False,
        help=("Print the names of the GUI plugins and exit. Note that the "
              "displayed plugins are not affected by the `include-plugins` "
              "and `exclude-plugins` options"))
    if info_grp is not None:
        parser.unfinished_arguments['list_gui_plugins']['group'] = info_grp

    parser.pop_key('offline', 'short')

    parser.append2help('output_project',
                       '. This option has only an effect if the `output` '
                       ' option is set.')

    parser.update_arg('use_all', short='a')

    parser.pop_arg('exec_')
    parser.pop_arg('callback')

    parser.pop_key('webengineview', 'short')
    parser.update_arg('webengineview', default=None, action='store_true',
                      group=gui_grp)

    parser.unfinished_arguments['no-webengineview'] = dict(
        long='no-webengineview', default=None, action='store_false',
        dest='webengineview',
        help="Do not use HTML rendering.",
        group=gui_grp)

    if psyplot.__version__ < '1.0':
        parser.set_main(start_app)

    parser.epilog += """

If you omit the ``'-o'`` option, the file is opened in the graphical user
interface and if you run::

    $ psyplot -pwd .

It will switch the directory of the already running GUI (if existent) to the
current working directory in your terminal. Additionally,::

    $ psyplot -s myscript.py

will run the file ``'myscript.py'`` in the GUI and::

    $ psyplot -c 'print("Hello World!")'

will execute ``print("Hello World")`` in the GUI. The output, of the `-s` and
`-c` options, will, however, be shown in the terminal."""

    if create:
        parser.create_arguments()

    return parser
Ejemplo n.º 4
0
def get_parser(create=True):
    """Return a parser to make that can be used to make plots or open files
    from the command line

    Returns
    -------
    psyplot.parser.FuncArgParser
        The :class:`argparse.ArgumentParser` instance

    See Also
    --------
    psyplot.main.get_parser
    psyplot.parser.FuncArgParser
    psyplot.main.main"""
    from psyplot.__main__ import get_parser
    parser = get_parser(create=False)

    parser.setup_args(start_app)

    gui_grp = parser.add_argument_group(
        'Gui options',
        'Options specific to the graphical user interface')

    parser.update_arg(
        'backend', short='b', const=None, nargs='?', metavar='backend',
        help="""
        The backend to use. By default, the ``'gui.backend'`` key in the
        :attr:`~psyplot_gui.config.rcsetup.rcParams` dictionary is used. If
        used without options, the default matplotlib backend is used.""",
        group=gui_grp)

    parser.update_arg('new_instance', short='ni', group=gui_grp)

    parser.update_arg('rc_gui_file', short='rc-gui', group=gui_grp)
    parser.pop_key('rc_gui_file', 'metavar')
    parser.update_arg('include_plugins', short='inc', group=gui_grp,
                      default=rcParams['plugins.include'])
    parser.append2help('include_plugins', '. Default: %(default)s')
    parser.update_arg('exclude_plugins', short='exc', group=gui_grp,
                      default=rcParams['plugins.exclude'])
    parser.append2help('exclude_plugins', '. Default: %(default)s')

    parser.update_arg('offline', group=gui_grp)
    parser.update_arg('pwd', group=gui_grp)
    parser.update_arg('script', short='s', group=gui_grp)
    parser.update_arg('command', short='c', group=gui_grp)
    # add an action to display the GUI plugins
    info_grp = parser.unfinished_arguments['list_plugins'].get('group')
    parser.update_arg(
        'list_gui_plugins', short='lgp', long='list-gui-plugins',
        action=ListGuiPluginsAction, if_existent=False,
        help=("Print the names of the GUI plugins and exit. Note that the "
              "displayed plugins are not affected by the `include-plugins` "
              "and `exclude-plugins` options"))
    if info_grp is not None:
        parser.unfinished_arguments['list_gui_plugins']['group'] = info_grp

    parser.pop_key('offline', 'short')

    parser.append2help('output_project',
                       '. This option has only an effect if the `output` '
                       ' option is set.')

    parser.update_arg('use_all', short='a')

    parser.pop_arg('exec_')
    parser.pop_arg('callback')

    if psyplot.__version__ < '1.0':
        parser.set_main(start_app)

    parser.epilog += """

If you omit the ``'-o'`` option, the file is opened in the graphical user
interface and if you run::

    $ psyplot -pwd .

It will switch the directory of the already running GUI (if existent) to the
current working directory in your terminal. Additionally,::

    $ psyplot -s myscript.py

will run the file ``'myscript.py'`` in the GUI and::

    $ psyplot -c 'print("Hello World!")'

will execute ``print("Hello World")`` in the GUI. The output, of the `-s` and
`-c` options, will, however, be shown in the terminal."""

    if create:
        parser.create_arguments()

    return parser