'Load image/document/etc from a local path or url.'

def load_file(self, url=None, local_path=None, username=None, password=None, auth=None):

    try:
        if (url is not None):
            if ((username is not None) and (password is not None)):
                if (ATTR_FILE_AUTH_DIGEST == auth):
                    auth_ = HTTPDigestAuth(username, password)
                else:
                    auth_ = HTTPBasicAuth(username, password)
                req = requests.get(url, auth=auth_, timeout=CONF_TIMEOUT)
            else:
                req = requests.get(url, timeout=CONF_TIMEOUT)
            return req.content
        elif (local_path is not None):
            if self.is_allowed_path(local_path):
                return open(local_path, 'rb')
            _LOGGER.warning("'%s'    is    not    secure    to    load    data    from!", local_path)
        else:
            _LOGGER.warning('Neither    url    nor    local    path    found    in    params!')
    except OSError as error:
        _LOGGER.error("Can't    load    from    url    or    local    path:    %s", error)
    return None
