def group_locations(locations, expand_dir=False):
    '\n    Divide a list of locations into two groups: "files" (archives) and "urls."\n\n    :return: A pair of lists (files, urls).\n    '
    files = []
    urls = []

    def sort_path(path):
        url = path_to_url(path)
        if (mimetypes.guess_type(url, strict=False)[0] == 'text/html'):
            urls.append(url)
        else:
            files.append(url)
    for url in locations:
        is_local_path = os.path.exists(url)
        is_file_url = url.startswith('file:')
        if (is_local_path or is_file_url):
            if is_local_path:
                path = url
            else:
                path = url_to_path(url)
            if os.path.isdir(path):
                if expand_dir:
                    path = os.path.realpath(path)
                    for item in os.listdir(path):
                        sort_path(os.path.join(path, item))
                elif is_file_url:
                    urls.append(url)
                else:
                    logger.warning("Path '{0}' is ignored: it is a directory.".format(path))
            elif os.path.isfile(path):
                sort_path(path)
            else:
                logger.warning("Url '%s' is ignored: it is neither a file nor a directory.", url)
        elif is_url(url):
            urls.append(url)
        else:
            logger.warning("Url '%s' is ignored. It is either a non-existing path or lacks a specific scheme.", url)
    return (files, urls)
Divide a list of locations into two groups: "files" (archives) and "urls."

:return: A pair of lists (files, urls).
def group_locations(locations, expand_dir=False):
    '\n    Divide a list of locations into two groups: "files" (archives) and "urls."\n\n    :return: A pair of lists (files, urls).\n    '
    files = []
    urls = []

    def sort_path(path):
        url = path_to_url(path)
        if (mimetypes.guess_type(url, strict=False)[0] == 'text/html'):
            urls.append(url)
        else:
            files.append(url)
    for url in locations:
        is_local_path = os.path.exists(url)
        is_file_url = url.startswith('file:')
        if (is_local_path or is_file_url):
            if is_local_path:
                path = url
            else:
                path = url_to_path(url)
            if os.path.isdir(path):
                if expand_dir:
                    path = os.path.realpath(path)
                    for item in os.listdir(path):
                        sort_path(os.path.join(path, item))
                elif is_file_url:
                    urls.append(url)
                else:
                    logger.warning("Path '{0}' is ignored: it is a directory.".format(path))
            elif os.path.isfile(path):
                sort_path(path)
            else:
                logger.warning("Url '%s' is ignored: it is neither a file nor a directory.", url)
        elif is_url(url):
            urls.append(url)
        else:
            logger.warning("Url '%s' is ignored. It is either a non-existing path or lacks a specific scheme.", url)
    return (files, urls)