@classmethod
def from_stream(cls, stream, parser=None):
    """
        Construct a :class:`Config` from a stream such as a :func:`file <open>`.
        If the stream does not have a ``name`` attribute from which the correct
        parser can be guessed, :doc:`parser <parsers>` must be specified.
        If ``text`` is provided as :class:`bytes`, then the ``encoding``
        specified will be used to decode it.
        """
    if parser is None:
        name = getattr(stream, 'name', None)
        if name is not None:
            try:
                _, parser = name.rsplit('.', 1)
            except ValueError:
                pass
    if not callable(parser):
        parser = cls.parsers[parser]
    return cls(parser(stream))
