Coverage for lib/ansible/parsing/yaml/constructor.py : 79%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
# Most of this is from yaml.constructor.SafeConstructor. We replicate # it here so that we can warn users when they have duplicate dict keys # (pyyaml silently allows overwriting keys) raise ConstructorError(None, None, "expected a mapping node, but found %s" % node.id, node.start_mark)
# Add our extra information to the returned value
except TypeError as exc: raise ConstructorError("while constructing a mapping", node.start_mark, "found unacceptable key (%s)" % exc, key_node.start_mark)
display.warning(u'While constructing a mapping from {1}, line {2}, column {3}, found a duplicate dict key ({0}).' u' Using last defined value only.'.format(key, *mapping.ansible_pos))
# Override the default string handling function # to always return unicode objects
ret = wrap_var(ret)
value = self.construct_scalar(node) b_ciphertext_data = to_bytes(value) # could pass in a key id here to choose the vault to associate with # TODO/FIXME: plugin vault selector vault = self._vaults['default'] if vault.secrets is None: raise ConstructorError(context=None, context_mark=None, problem="found !vault but no vault password provided", problem_mark=node.start_mark, note=None) ret = AnsibleVaultEncryptedUnicode(b_ciphertext_data) ret.vault = vault return ret
return self.construct_yaml_str(node, unsafe=True)
# the line number where the previous token has ended (plus empty lines) # Add one so that the first line is line 1 rather than line 0
# in some cases, we may have pre-read the data and then # passed it to the load() call for YAML, in which case we # want to override the default datasource (which would be # '<string>') to the actual filename we read in
u'tag:yaml.org,2002:map', AnsibleConstructor.construct_yaml_map)
u'tag:yaml.org,2002:python/dict', AnsibleConstructor.construct_yaml_map)
u'tag:yaml.org,2002:str', AnsibleConstructor.construct_yaml_str)
u'tag:yaml.org,2002:python/unicode', AnsibleConstructor.construct_yaml_str)
u'tag:yaml.org,2002:seq', AnsibleConstructor.construct_yaml_seq)
u'!unsafe', AnsibleConstructor.construct_yaml_unsafe)
u'!vault', AnsibleConstructor.construct_vault_encrypted_unicode)
|