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

from ppms.migration.packet import *


class __FindSQLUsagePacket__(DeprecatedPythonPacket):
    '''Search Python code base for usage of SQL.

    This packet only serves as a source of documentation and
    writes its findings to the logfile.
    '''

    wi_number = 10966
    version = 1
    category = PacketCategory.CATEGORY_HELPER

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

        # Load the full thing into memory, we don't have that much source code :P
        return list(filter(search, iterable_to_filter))