File: Feature.py

package info (click to toggle)
python-pyvmomi 9.0.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,372 kB
  • sloc: python: 18,622; xml: 77; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 987 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (c) 2021-2024 Broadcom. All Rights Reserved.
# The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.

# Deprecated
# Support for pyVmomi features states

from collections import namedtuple
from . import _assert_not_initialized

# pyVmomi features along with their default states.
# e.g., 'newFeature': False
_features = {
}

Features = namedtuple('Features', _features.keys())
flags = Features(**_features)


def _init():
    global flags
    flags = Features(**_features)


def get_feature_names():
    return _features.keys()


def set_feature_state(feature_name, state):
    _assert_not_initialized()
    if feature_name not in _features:
        raise AttributeError("Feature '{0}' is not supported!".format(feature_name))
    if not isinstance(feature_name, str):
        raise TypeError("Feature name should be string!")
    if not isinstance(state, bool):
        raise TypeError("Feature state should be boolean!")

    _features[feature_name] = state