The code changes are to generate metadata.yaml, config.yaml, unithooks from tosca template.

Something like this .. that would perform all of the filtering / validation you wanted to do. This results in cleaner code below.
try:
    requirements = self._prepare_requirements(node.get_item(Node.REQUIREMENTS)
except RequirementsValidationError:
    # do some reporting / feedback