11. 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.

11.1. Functions defined in module cmdtools

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.list_modules(pkgs=['all'])[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’].

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.migrateUserConfig()[source]

Migrate the user preferences in $HOME/.config

Conversion of old style has been abandoned. Currently this does nothing.

cmdtools.apply_config_changes(cfg)[source]

Apply incompatible changes in the configuration

cfg is the user configuration that is to be saved.

cmdtools.savePreferences()[source]

Save the preferences.

The name of the preferences file is determined at startup from the configuration files, and saved in pyformex.preffile. If a local preferences file was read, it will be saved there. Otherwise, it will be saved as the user preferences, possibly creating that file. If pyformex.preffile is None, preferences are not saved.

cmdtools.activateWarningFilters()[source]

Activate the warning filters

First time activation of the warning filters and customized warning formatting.