40. pyformex — pyFormex core module initialization.

This module initializes the pyFormex global variables and defines a few essential functions. It is the very first thing that is loaded when starting pyFormex.

40.1. Classes defined in module pyformex

class pyformex.FatalError(msg)[source]

Raised on fatal or grave errors

class pyformex.RequirementsError(msg)[source]

Raised on missing or invalid requirements

class pyformex.ImplementationError(msg)[source]

Raised on clear implementation errors

class pyformex.DEBUG(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

A class with debug items.

This class holds the defined debug items as attributes. Each debug topic is a binary value with a single bit set (a power of 2). Debug items can be combined with & (AND), | (OR) and ^ (XOR). Two extra values are defined: NONE switches off all debugging, ALL activates all debug items.

Examples

List all existing debug items:

>>> for v in DEBUG:
...     if v not in (DEBUG.NONE, DEBUG.ALL):
...         print(v)
DEBUG.INFO
DEBUG.WARNING
DEBUG.CONFIG
DEBUG.DETECT
DEBUG.HELP
DEBUG.MEM
DEBUG.SCRIPT
DEBUG.GUI
DEBUG.MENU
DEBUG.DRAW
DEBUG.CANVAS
DEBUG.OPENGL
DEBUG.LIB
DEBUG.MOUSE
DEBUG.APPS
DEBUG.IMAGE
DEBUG.PICK
DEBUG.MISC
DEBUG.ABQ
DEBUG.WIDGET
DEBUG.PROJECT
DEBUG.WEBGL
DEBUG.MULTI
DEBUG.LEGACY
DEBUG.PLUGIN
DEBUG.UNICODE
DEBUG.FONT
DEBUG.PGF
DEBUG.VTK
DEBUG.DOCTEST
classmethod item(name)[source]

Convert a string to a DEBUG item

The string is case insensitive.

Raises:

ValueError – If the name is not a DEBUG item.

classmethod level(names)[source]

Return the combined debug level for a list of debug items

Raises:

ValueError – If any of the names is not a DEBUG item.

40.2. Functions defined in module pyformex

pyformex.Version()[source]

Return a string with the pyFormex name and version

pyformex.fullVersion()[source]

Return a string with the pyFormex name, version and revision

pyformex.major(v)[source]

Return the major component of version

pyformex.minor(v)[source]

Return the minor component of version

pyformex.human_version(v)[source]

Return the human readable string for version

pyformex.run_cmd(cmd)[source]

Run command

pyformex.busy(state=True)[source]

Flag a busy state to the user

pyformex.onExit(func)[source]

Register a function to be called on exit from pyFormex

pyformex.debugon(topics)[source]

Return True if any of specified debug topics is in options.debuglevel.

Parameters:

topics (DEBUG) – A DEBUG topic or any combination of them.

Returns:

bool – True if any of the flags in topics is in options.debuglevel. This is effectively the bool value of the binary AND of topics and options.debuglevel.

Note

If you need to test that multiple flags are in options.debuglevel, use debugon(flag1) & debugon(flag2)

Examples

>>> options.debuglevel = DEBUG.INFO | DEBUG.OPENGL | DEBUG.GUI | DEBUG.MENU
>>> debugon(DEBUG.WARNING | DEBUG.OPENGL)
True
>>> debugon(DEBUG.WARNING & DEBUG.OPENGL)
False
>>> debugon(DEBUG.WARNING & DEBUG.OPENGL | DEBUG.GUI)
True
>>> debugon(DEBUG.OPENGL) & debugon(DEBUG.GUI)
True
>>> debugon(DEBUG.ALL)
True
>>> options.debuglevel = DEBUG.NONE
>>> debugon(DEBUG.ALL)
False
pyformex.verbosity(verbose)[source]

Check that verbosity is equal or higher than given value

pyformex.verbose(verbose, *args, **kargs)[source]

Print a message if the verbosity is high enough

pyformex.run(args)[source]

Run pyFormex from a Python shell

Parameters:

args (str) – The arguments for pyformex like thy would be entered on the pyformex command line in a shell.