Set the policy from environment variables.
(cls)
| 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 |