def filter_spec(spec, paths, wildcard='<STR_LIT:*>', separator='<STR_LIT:/>'):
def remove_key(path, spec):<EOL><INDENT>if len(path) == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>elif len(path) == <NUM_LIT:1>:<EOL><INDENT>key = path.pop()<EOL>if not isinstance(spec, collections.Mapping):<EOL><INDENT>raise LagoUserException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>key=key, spec_type=type(spec)<EOL>)<EOL>)<EOL><DEDENT>if key == wildcard:<EOL><INDENT>spec.clear()<EOL><DEDENT>else:<EOL><INDENT>spec.pop(key, None)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>current = path[<NUM_LIT:0>]<EOL>if current == wildcard:<EOL><INDENT>if isinstance(spec, list):<EOL><INDENT>iterator = iter(spec)<EOL><DEDENT>elif isinstance(spec, collections.Mapping):<EOL><INDENT>iterator = iter(spec.values())<EOL><DEDENT>else:<EOL><INDENT>raise LagoUserException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>char=wildcard, spec_type=type(spec)<EOL>)<EOL>)<EOL><DEDENT>for i in iterator:<EOL><INDENT>remove_key(path[<NUM_LIT:1>:], i)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>remove_key(path[<NUM_LIT:1>:], spec[current])<EOL><DEDENT>except KeyError:<EOL><INDENT>raise LagoUserException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(key=current)<EOL>)<EOL><DEDENT>except TypeError:<EOL><INDENT>raise LagoUserException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>spec_type=type(spec)<EOL>)<EOL>)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for path in paths:<EOL><INDENT>try:<EOL><INDENT>remove_key(path.split(separator), spec)<EOL><DEDENT>except LagoUserException as e:<EOL><INDENT>e.message = e.message.format(path=path)<EOL>raise<EOL><DEDENT><DEDENT>
Remove keys from a spec file.
For example, with the following path: domains/*/disks/*/metadata
all the metadata dicts from all domains disks will be removed.

Args:
    spec (dict): spec to remove keys from
    paths (list): list of paths to the keys that should be removed
    wildcard (str): wildcard character
    separator (str): path separator

Returns:
    None

Raises:
    utils.LagoUserException: If a malformed path was detected