MCPcopy Create free account
hub / github.com/PyTables/PyTables / set_policy_from_env

Method set_policy_from_env

tables/exceptions.py:105–129  ·  view source on GitHub ↗

Set the policy from environment variables.

(cls)

Source from the content-addressed store, hash-verified

103
104 @classmethod
105 def set_policy_from_env(cls) -> str:
106 """Set the policy from environment variables."""
107 envmap = {
108 "IGNORE": False,
109 "FALSE": False,
110 "SAVE": True,
111 "TRUE": True,
112 "VERBOSE": "VERBOSE",
113 "DEFAULT": "VERBOSE",
114 }
115 oldvalue = cls.DEFAULT_H5_BACKTRACE_POLICY
116 envvalue = os.environ.get("PT_DEFAULT_H5_BACKTRACE_POLICY", "DEFAULT")
117 try:
118 newvalue = envmap[envvalue.upper()]
119 except KeyError:
120 warnings.warn(
121 "Invalid value for the environment variable "
122 "'PT_DEFAULT_H5_BACKTRACE_POLICY'. The default "
123 "policy for HDF5 back trace management in PyTables "
124 "will be: '%s'" % oldvalue
125 )
126 else:
127 cls.DEFAULT_H5_BACKTRACE_POLICY = newvalue
128
129 return oldvalue
130
131 def __init__(self, *args, **kargs) -> None:
132

Callers 1

exceptions.pyFile · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected