Coverage for lib/ansible/playbook/role/metadata.py : 68%

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) 2014 Michael DeHaan, <michael@ansible.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
''' This class wraps the parsing and validation of the optional metadata within each Role (meta/main.yml). '''
''' Returns a new RoleMetadata object based on the datastructure passed in. '''
raise AnsibleParserError("the 'meta/main.yml' for role %s is not a dictionary" % owner.get_name())
''' This is a helper loading function for the dependencies list, which returns a list of RoleInclude objects '''
raise AnsibleParserError("Expected role dependencies to be a list.", obj=self._ds)
try: # role_def is new style: { src: 'galaxy.role,version,name', other_vars: "here" } def_parsed = RoleRequirement.role_yaml_parse(role_def) if def_parsed.get('name'): role_def['name'] = def_parsed['name'] roles.append(role_def) except AnsibleError as exc: raise AnsibleParserError(str(exc), obj=role_def, orig_exc=exc)
loader=self._loader) except AssertionError as e: raise AnsibleParserError("A malformed list of role dependencies was encountered.", obj=self._ds, orig_exc=e)
''' This is a helper loading function for the galaxy info entry in the metadata, which returns a GalaxyInfo object rather than a simple dictionary. '''
return ds
return dict( allow_duplicates=self._allow_duplicates, dependencies=self._dependencies, )
setattr(self, 'allow_duplicates', data.get('allow_duplicates', False)) setattr(self, 'dependencies', data.get('dependencies', [])) |