WiseAgentsYAMLObject
Bases: YAMLObject
Abstract class to deal with removing the underscores from the keys of the parsed YAML object.
Source code in wiseagents/yaml/wiseagents_yaml_object.py
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
__getstate__()
Gets the state of the object for serialization to YAML/Pickle. This converts the keys from their internal representation with leading underscores to the external representation, which have no leading underscores.
Note: subclasses overriding this method should call super().getstate() to get the state that will be serialized to YAML/Pickle, rather than calling self.dict directly.
Note: when overriding this method and getting the state, e.g. for deleting entries which should not be serialized, the entries in the map will have keys in the external form (i.e. no leading underscores).
Returns: |
|
---|
Source code in wiseagents/yaml/wiseagents_yaml_object.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
__setstate__(d)
Sets the state of the object from the parsed representation of the YAML or from Pickle. This does conversion of the keys read, which have no leading underscores to the internal representation in the class which have leading underscores.
Note: Subclasses MAY override this method, but need to be aware that the keys in the dictionary will not have underscores, and once done they will need to call this method via a super().setstate(d) call.
Note: Rather than overriding setstate(), it is preferred to override _validate_and_convert_types(), which will be called once conversion has been done, and have the keys in the dictionary with underscores.
Parameters: |
|
---|
Returns: |
|
---|
Source code in wiseagents/yaml/wiseagents_yaml_object.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
setup_yaml_for_env_vars()
Configures the YAML Loader to do replacement of environment variables.
It will replace YAML value strings such as '${HOST}' and '${PORT:80}' with environment
variable lookups.
In the first example, '${HOST}', it will replace the string with the value from doing
os.getenv("HOST")
. If the environment variable 'HOST" is not set, an exception will be thrown.
In the second example, '${PORT:80}', we are doing the same but looking up `os.getenv("PORT"). In this case,
if the 'PORT' environment variable is not set, it will use the default value shows, which in this case is '80'.
Source code in wiseagents/yaml/wise_yaml_loader.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|