def __init__(self,
                 source,
                 include_regex='^%include\s"([^"]+)"',
                 max_nest_level=100,
                 output=None):
        """
        Create a new ``Includer`` object.

        :Parameters:
            source : file or str
                The source to be read and expanded. May be an open file-like
                object, a path name, or a URL string.
            include_regex : str
                Regular expression defining the include syntax. Must contain a
                single parenthetical group that can be used to extract the
                included file or URL.
            max_nest_level : int
                Maximum include nesting level. Exceeding this level will cause
                ``Includer`` to throw an ``IncludeError``.
            output : str or file
                A string (path name) or file-like object to which to save the
                expanded output.

        :raise IncludeError: On error
        """

        if isinstance(source, str):
            f, is_url, name = self.__open(source, None, False)
        else:
            # Assume file-like object.
            f = source
            is_url = False
            try:
                name = source.name
            except __HOLE__:
                name = None

        self.closed = False
        self.mode = None
        self.__include_pattern = re.compile(include_regex)
        self.__name = name

        if output == None:
            from cStringIO import StringIO
            output = StringIO()

        self.__maxnest = max_nest_level
        self.__nested = 0
        self.__process_includes(f, name, is_url, output)
        self.__f = output
        self.__f.seek(0)
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/grizzled/grizzled/file/includer.py/Includer.__init__