def get_path_from_stream(strm):
    """
    Try to get file path from given file or file-like object 'strm'.

    :param strm: A file or file-like object
    :return: Path of given file or file-like object or None
    :raises: ValueError

    >>> assert __file__ == get_path_from_stream(open(__file__, 'r'))
    >>> assert get_path_from_stream(anyconfig.compat.StringIO()) is None
    >>> get_path_from_stream(__file__)  # doctest: +ELLIPSIS
    Traceback (most recent call last):
        ...
    ValueError: ...
    """
    if not is_file_stream(strm):
        raise ValueError("Given object does not look a file/file-like "
                         "object: %r" % strm)

    path = getattr(strm, "name", None)
    if path is not None:
        try:
            return normpath(path)
        except (TypeError, ValueError):
            pass

    return None
def get_path_from_stream ( strm ) : if not is_file_stream ( strm ) : raise ValueError ( "Given object does not look a file/file-like " "object: %r" % strm ) path = getattr ( strm , "name" , None ) if path is not None : try : return normpath ( path ) except ( TypeError , ValueError ) : pass return None
Try to get file path from given file or file-like object 'strm'.

    :param strm: A file or file-like object
    :return: Path of given file or file-like object or None
    :raises: ValueError

    >>> assert __file__ == get_path_from_stream(open(__file__, 'r'))
    >>> assert get_path_from_stream(anyconfig.compat.StringIO()) is None
    >>> get_path_from_stream(__file__)  # doctest: +ELLIPSIS
    Traceback (most recent call last):
        ...
    ValueError: ...