View source on GitHub |
Class representing a mapping of environment variable key/value pairs.
Inherits From: ValidatedDict
, ValidatedBase
, expected_type
google.appengine.api.appinfo.EnvironmentVariables(
**kwds
)
Args | |
---|---|
**kwds
|
keyword arguments will be validated and put into the dict. |
Methods
CheckInitialized
CheckInitialized()
Checks for missing or conflicting attributes.
Subclasses should override this function and raise an exception for any errors. Always run this method when all assignments are complete.
Raises | |
---|---|
ValidationError
|
When there are missing or conflicting attributes. |
GetValidator
@classmethod
GetValidator( key )
Check the key for validity and return a corresponding value validator.
Args | |
---|---|
key
|
The key that will correspond to the validator we are returning. |
GetWarnings
GetWarnings()
Return all the warnings we've got, along with their associated fields.
Returns | |
---|---|
A list of tuples of (dotted_field, warning), both strings. |
KEY_VALIDATOR
KEY_VALIDATOR(
key='???'
)
Regular expression validator.
Regular expression validator always converts value to string. Note that matches must be exact. Partial matches will not validate. For example:
class ClassDescr(Validated): ATTRIBUTES = { 'name': Regex(r'[a-zA-Z_][a-zA-Z_0-9]*'), 'parent': Type(type)` }
Alternatively, any attribute that is defined as a string is automatically interpreted to be of type Regex. It is possible to specify unicode regex strings as well. This approach is slightly less efficient, but usually is not significant unless parsing large amounts of data:
class ClassDescr(Validated):
ATTRIBUTES = { 'name': r'[a-zA-Z_][a-zA-Z_0-9]*',
'parent': Type(type),
}
# This will raise a ValidationError exception.
my_class(name='AName with space', parent=AnotherClass)
Merge
@classmethod
Merge( env_variables_one, env_variables_two )
Merges two EnvironmentVariables
instances.
If a variable is specified by both instances, the value from
env_variables_two
is used.
Args | |
---|---|
env_variables_one
|
The first EnvironmentVariables instance or None .
|
env_variables_two
|
The second EnvironmentVariables instance or None .
|
Returns | |
---|---|
The merged EnvironmentVariables instance, or None if both input
instances are None or empty.
|
Set
Set(
key, value
)
Set a single value on Validated
instance.
This method checks that a given key and value are valid and if so puts the item into this dictionary.
Args | |
---|---|
key
|
The name of the attributes. |
value
|
The value to set. |
Raises | |
---|---|
ValidationError
|
When no validated attribute exists on class. |
SetMultiple
SetMultiple(
attributes
)
Set multiple values on Validated instance.
All attributes will be validated before being set.
Args | |
---|---|
attributes
|
A dict of attributes/items to set. |
Raises | |
---|---|
ValidationError
|
When no validated attribute exists on class. |
ToDict
ToDict()
Convert ValidatedBase
object to a dictionary.
Recursively traverses all of its elements and converts everything to simplified collections.
Subclasses should override this method.
Returns | |
---|---|
A dictionary mapping all attributes to simple values or collections. |
ToYAML
ToYAML()
Print validated object as simplified YAML.
Returns | |
---|---|
Object as a simplified YAML string compatible with parsing using the
SafeLoader .
|
clear
clear()
D.clear() -> None. Remove all items from D.
copy
copy()
D.copy() -> a shallow copy of D
fromkeys
fromkeys(
value, /
)
Create a new dictionary with keys from iterable and values set to value.
get
get(
key, default, /
)
Return the value for key if key is in the dictionary, else default.
items
items()
D.items() -> a set-like object providing a view on D's items
keys
keys()
D.keys() -> a set-like object providing a view on D's keys
pop
pop()
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem
popitem()
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
setdefault
setdefault(
key, value=None
)
Trap setdefaultss to ensure all key/value pairs are valid.
See the documentation for setdefault on dict for usage details.
Raises | |
---|---|
ValidationError
|
if the specified key is illegal or the value invalid. |
update
update(
other, **kwds
)
Trap updates to ensure all key/value pairs are valid.
See the documentation for update on dict for usage details.
Raises | |
---|---|
ValidationError
|
if any of the specified keys are illegal or values invalid. |
values
values()
D.values() -> an object providing a view on D's values
__contains__
__contains__(
key, /
)
True if the dictionary has the specified key, else False.
__eq__
__eq__(
value, /
)
Return self==value.
__ge__
__ge__(
value, /
)
Return self>=value.
__getitem__
__getitem__()
x.getitem(y) <==> x[y]
__gt__
__gt__(
value, /
)
Return self>value.
__iter__
__iter__()
Implement iter(self).
__le__
__le__(
value, /
)
Return self<=value.
__len__
__len__()
Return len(self).
__lt__
__lt__(
value, /
)
Return self<value.
__ne__
__ne__(
value, /
)
Return self!=value.
__or__
__or__(
value, /
)
Return self|value.
__ror__
__ror__(
value, /
)
Return value|self.