'Import item de-duplication'

@staticmethod
def document_duplicate(item):

    data = item.data
    query = None
    file = data.get('file')
    if file:
        table = item.table
        query = (table.file == file)
    else:
        url = data.get('url')
        if url:
            table = item.table
            query = (table.url == url)
    if query:
        duplicate = current.db(query).select(table.id, limitby=(0, 1)).first()
        if duplicate:
            item.id = duplicate.id
            item.method = item.METHOD.UPDATE
