|
|
@ -60,7 +60,7 @@ class AnsibleJ2Vars(Mapping):
|
|
|
|
self._locals[key] = val
|
|
|
|
self._locals[key] = val
|
|
|
|
|
|
|
|
|
|
|
|
def __contains__(self, k):
|
|
|
|
def __contains__(self, k):
|
|
|
|
if k in self._templar._available_variables:
|
|
|
|
if k in self._templar.available_variables:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
if k in self._locals:
|
|
|
|
if k in self._locals:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
@ -73,16 +73,16 @@ class AnsibleJ2Vars(Mapping):
|
|
|
|
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
def __iter__(self):
|
|
|
|
keys = set()
|
|
|
|
keys = set()
|
|
|
|
keys.update(self._templar._available_variables, self._locals, self._globals, *self._extras)
|
|
|
|
keys.update(self._templar.available_variables, self._locals, self._globals, *self._extras)
|
|
|
|
return iter(keys)
|
|
|
|
return iter(keys)
|
|
|
|
|
|
|
|
|
|
|
|
def __len__(self):
|
|
|
|
def __len__(self):
|
|
|
|
keys = set()
|
|
|
|
keys = set()
|
|
|
|
keys.update(self._templar._available_variables, self._locals, self._globals, *self._extras)
|
|
|
|
keys.update(self._templar.available_variables, self._locals, self._globals, *self._extras)
|
|
|
|
return len(keys)
|
|
|
|
return len(keys)
|
|
|
|
|
|
|
|
|
|
|
|
def __getitem__(self, varname):
|
|
|
|
def __getitem__(self, varname):
|
|
|
|
if varname not in self._templar._available_variables:
|
|
|
|
if varname not in self._templar.available_variables:
|
|
|
|
if varname in self._locals:
|
|
|
|
if varname in self._locals:
|
|
|
|
return self._locals[varname]
|
|
|
|
return self._locals[varname]
|
|
|
|
for i in self._extras:
|
|
|
|
for i in self._extras:
|
|
|
@ -93,7 +93,7 @@ class AnsibleJ2Vars(Mapping):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise KeyError("undefined variable: %s" % varname)
|
|
|
|
raise KeyError("undefined variable: %s" % varname)
|
|
|
|
|
|
|
|
|
|
|
|
variable = self._templar._available_variables[varname]
|
|
|
|
variable = self._templar.available_variables[varname]
|
|
|
|
|
|
|
|
|
|
|
|
# HostVars is special, return it as-is, as is the special variable
|
|
|
|
# HostVars is special, return it as-is, as is the special variable
|
|
|
|
# 'vars', which contains the vars structure
|
|
|
|
# 'vars', which contains the vars structure
|
|
|
|