def delete(self, key_name):
self._assert_valid_stash()<EOL>if key_name == '<STR_LIT>':<EOL><INDENT>raise GhostError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if not self.get(key_name):<EOL><INDENT>raise GhostError('<STR_LIT>'.format(key_name))<EOL><DEDENT>key = self._storage.get(key_name)<EOL>if key.get('<STR_LIT>'):<EOL><INDENT>raise GhostError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(key_name))<EOL><DEDENT>deleted = self._storage.delete(key_name)<EOL>audit(<EOL>storage=self._storage.db_path,<EOL>action='<STR_LIT>',<EOL>message=json.dumps(dict(key_name=key_name)))<EOL>if not deleted:<EOL><INDENT>raise GhostError('<STR_LIT>'.format(key_name))<EOL><DEDENT>
Delete a key if it exists.