def get_descriptor(file_input, read=True):
    try:
        # Is it a file like object?
        file_input.seek(0)
    except __HOLE__:
        # If not, try open it.
        if read:
            return open(file_input, 'rb')
        else:
            return open(file_input, 'wb')
    else:
        return file_input
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/common/utils.py/get_descriptor