# -*- coding: utf-8 -*-
import re

from ppms.migration.packet import *
from ppms.migration import MinVersionDependency


class TryExceptWithoutFilterExceptionType(DeprecatedPythonPacket):
    """Used to find all occurrences of 'except:' in the customzing and the server files"""

    wi_number = 10657
    version = 1
    category = PacketCategory.CATEGORY_HELPER

    def get_dependencies(self):
        return (MinVersionDependency(version='39.5'))

    def get_matching_objects(self, iterable_to_filter):
        search = lambda x: re.search('except:', x.source)

        return list(filter(search, iterable_to_filter))
