def __call__(self, item):

        data = item.data
        table = item.table

        query = None
        error = "Invalid field for duplicate detection: %s (%s)"
        match = self.match

        # Primary query (mandatory)
        primary = self.primary
        for fname in primary:

            if fname not in table.fields:
                raise SyntaxError(error % (fname, table))

            field = table[fname]
            value = data.get(fname)

            q = self.match(field, value)
            query = q if query is None else query & q

        # Secondary queries (optional)
        secondary = self.secondary
        for fname in secondary:

            if fname not in table.fields:
                raise SyntaxError(error % (fname, table))

            field = table[fname]
            value = data.get(fname)
            if value:
                query &= self.match(field, value)

        # Ignore deleted records?
        if self.ignore_deleted and "deleted" in table.fields:
            query &= (table.deleted != True)

        # Find a match
        duplicate = current.db(query).select(table._id,
                                             limitby = (0, 1)).first()

        # Update import item if match found:
        if duplicate:
            item.id = duplicate[table._id]
            if not data.deleted:
                item.method = item.METHOD.UPDATE

        # For uses outside of imports:
        return duplicate

    # -------------------------------------------------------------------------
Entry point for importer
dataset/ETHPy150Open sahana/eden/modules/s3/s3import.py/S3Duplicate.__call__