_backwardscompatibilityhelper Module

Internal module used by paraview.servermanager to help warn about proxies/properties changed or removed. To help with backward compatibility, the _backwardscompatibilityhelper module should be updated to handle deprecated proxies and properties.

Each proxy is associated to a kind of python class. When a proxy is removed, this class is no more generated and older scripts will raise NameError exception. To avoid this, deprecated proxies should be added in get_deprecated_proxies returned map, so a fallback proxy can be used. See also GetProxy.

Properties are defined as attribute of the python object. When a property is removed, old scripts using it will fail with AttributeError. When everything else fails, NotSupportedException is thrown. See setattr and getattr methods.

Each compatibility code is called depending on the current version and on the compatibility version asked by the script. Compatibility version should be specified before importing simple module. For instance: ` import paraview paraview.compatibility.major=5 paraview.compatibility.minor=11 from paraview.simple import * ` Will create fallback proxies and properties for deprecation done since 5.11 and will fail for object deprecated before 5.11.

exception paraview._backwardscompatibilityhelper.Continue[source]

Bases: Exception

paraview._backwardscompatibilityhelper.GetProxy(module, key, **kwargs)[source]
paraview._backwardscompatibilityhelper.get_deprecated_proxies(proxiesNS)[source]

Provide a map between deprecated proxies and their fallback proxy The key is the previous name, value the new. By name we mean the actual python method name to construct the proxy, not the proxy name. Python method name is constructed from proxy label, sanitized to be a valid python method name.

paraview._backwardscompatibilityhelper.get_paraview_compatibility_version()[source]

Returns the compatibility version set by the user. If the compatibility version is set, it also checks if the compatibility version is greater or less than the current version and prints a warning.

paraview._backwardscompatibilityhelper.getattr(proxy, pname)[source]

Attempts to emulate getattr() when called using a deprecated property name for a proxy.

Will return a reasonable stand-in if the property was deprecated and the paraview compatibility version was set to a version older than when the property was deprecated.

Will raise NotSupportedException if the property was deprecated and paraview compatibility version is newer than that deprecation version.

Will raise Continue to indicate the property name is unaffected by any API deprecation and the caller should follow normal code execution paths.

paraview._backwardscompatibilityhelper.lookupTableUpdate(lutName)[source]

Provide backwards compatibility for color lookup table name changes.

paraview._backwardscompatibilityhelper.setattr(proxy, pname, value)[source]

Attempts to emulate setattr() when called using a deprecated name for a proxy property.

For properties that are no longer present on a proxy, the code should do the following:

  1. If compatibility_version is less than the version in which the property was removed, attempt to handle the request and raise Continue to indicate that the request has been handled. If it is too complicated to support the old API, then it is acceptable to raise a warning message, but don’t raise an exception.

  2. If compatibility version is >= the version in which the property was removed, raise NotSupportedException with details including suggestions to update the script.

paraview._backwardscompatibilityhelper.setattr_fix_value(proxy, pname, value, setter_func)[source]