7. cmdtools — pyFormex command line tools

This module contains some command line tools that are run through the pyformex command, but do not start a full pyFormex program: just execute some small task and exit.

Furthermore it contains some functions for handling the user preferences.

7.1. Functions defined in module cmdtools

cmdtools.whereami()[source]

Report where pyFormex is installed

cmdtools.run_docmodule(module)[source]

Print autogenerated documentation for the module.

module is a pyFormex module dotted path. The leading pyformex. may be omitted.

cmdtools.moduleList(package='all')[source]

Return a list of all pyFormex modules in a subpackage.

This is like sourceFiles(), but returns the files in a Python module syntax.

cmdtools.list_modules(pkgs=['all'], sphinx=False)[source]

Return the list of pure Python modules in a pyFormex subpackage.

Parameters:
  • pkgs (list of str) –

    A list of pyFormex subpackage names. The subpackage name is a subdirectory of the main pyformex package directory. Two special package names are recognized:

    • ’core’: returns the modules in the top level pyformex package

    • ’all’: returns all pyFormex modules

    An empty list is interpreted as [‘all’].

  • sphinx (bool) – If True, some modules that are known to fail with sphinx are not listed. This is mainly intended for use from within sphinx.

Returns:

list of str – A list of all modules in the specified packages.

Notes

This implements the pyformex --listmodules functionality.

cmdtools.run_pytest(modules)[source]

Run the pytests for the specified pyFormex modules.

Parameters:

modules (list of str) – A list of pyFormex modules in dotted Python notation, relative to the pyFormex package. If an empty list is supplied, all available pytests will be run.

Notes

Test modules are stored under the path pf.cfg[‘testdir’], with the same hierarchy as the pyFormex source modules, and are named test_MODULE.py, where MODULE is the corresponding source module.

This implements the pyformex –pytest functionality.

cmdtools.run_doctest(modules)[source]

Run the doctests for the specified pyFormex modules.

Parameters:

modules (list of str) – A list of pyFormex modules in dotted Python notation, relative to the pyFormex package. If an empty list is supplied, all doctests in all pyFormex modules will be run.

Notes

Doctests are tests embedded in the docstrings of the Python source.

To allow consistent output of floats independent of machine precision, numpy’s floating point print precision is set to two decimals.

This implements the pyformex –doctest functionality.

cmdtools.doctest_module(module)[source]

Run the doctests in a single module’s docstrings.

All the doctests in the docstrings of the specified module will be run.

Parameters:

module (str) – A pyFormex module in dotted path notation. The leading ‘pyformex.’ can be omitted.

cmdtools.remove_pyFormex(pyformexdir, executable)[source]

Remove the pyFormex installation.

This will remove a pyFormex installation that was done using the ‘python setup.py install’ command from a source distribution in ‘tar.gz’ format. The procedure is interactive and will ask for confirmation.

Parameters:
  • pyformexdir (Path) – Absolute Path to the pyFormex installation directory.

  • executable (Path) – Path to the pyformex executable.

Notes

This implements the pyformex –remove functionality.

cmdtools.processOptions(options)[source]

Process options that run one of the command tools