def Func(arg_0, arg_1, arg_2=True):
        """
        subprocess run on here
        """
        arg_3 = arg_0.path
        with arg_0.cd(newdir=arg_3):
            if arg_2:
                arg_4 = sp.run(arg_1, stdout=sp.PIPE, stderr=sp.PIPE)
            else:
                arg_4 = sp.run(arg_1)
            return arg_4


def Func(arg_0, arg_1):
        """ Returns whether a reply from the kernel originated from a request
            from this frontend.
        """
        arg_2 = arg_0._kernel_manager.session.session
        arg_3 = arg_1['parent_header']
        if not arg_3:
            # if the message has no parent, assume it is meant for all frontends
            return True
        else:
            return arg_3.get('session') == arg_2


def Func(arg_0, arg_1, arg_2):
        """Annotate a single file.

        `cu` is the CodeUnit for the file to annotate.

        """
        if not arg_1.relative:
            return

        arg_3 = arg_1.filename
        arg_4 = arg_1.source_file()
        if arg_0.directory:
            arg_5 = os.path.join(arg_0.directory, arg_1.flat_rootname())
            arg_5 += ".py,cover"
        else:
            arg_5 = arg_3 + ",cover"
        arg_6 = open(arg_5, 'w')

        arg_7 = sorted(arg_2.statements)
        arg_8 = sorted(arg_2.missing)
        arg_9 = sorted(arg_2.excluded)

        arg_10 = 0
        arg_11 = 0
        arg_12 = 0
        arg_13 = True
        while True:
            arg_14 = arg_4.readline()
            if arg_14 == '':
                break
            arg_10 += 1
            while arg_11 < len(arg_7) and arg_7[arg_11] < arg_10:
                arg_11 += 1
            while arg_12 < len(arg_8) and arg_8[arg_12] < arg_10:
                arg_12 += 1
            if arg_11 < len(arg_7) and arg_7[arg_11] == arg_10:
                arg_13 = arg_12 >= len(arg_8) or arg_8[arg_12] > arg_10
            if arg_0.blank_re.match(arg_14):
                arg_6.write('  ')
            elif arg_0.else_re.match(arg_14):
                # Special logic for lines containing only 'else:'.
                if arg_11 >= len(arg_7) and arg_12 >= len(arg_8):
                    arg_6.write('! ')
                elif arg_11 >= len(arg_7) or arg_12 >= len(arg_8):
                    arg_6.write('> ')
                elif arg_7[arg_11] == arg_8[arg_12]:
                    arg_6.write('! ')
                else:
                    arg_6.write('> ')
            elif arg_10 in arg_9:
                arg_6.write('- ')
            elif arg_13:
                arg_6.write('> ')
            else:
                arg_6.write('! ')
            arg_6.write(arg_14)
        arg_4.close()
        arg_6.close()


def Func(arg_0):
    """Return a CouchDB database instance from a database string."""
    arg_1 = get_server_from_db(arg_0)
    arg_2 = PLAIN_RE.match(arg_0)
    arg_3 = URL_RE.match(arg_0)
    # If this looks like a local specifier:
    if arg_2:
        return arg_1[arg_2.groupdict()['database']]
    elif arg_3:
        return arg_1[arg_3.groupdict()['database']]
    raise ValueError('Invalid database string: %r' % (arg_0,))


def Func(arg_0):
    """Make sure a DB specifier exists, creating it if necessary."""
    arg_1 = LOCAL_RE.match(arg_0)
    arg_2 = REMOTE_RE.match(arg_0)
    arg_3 = PLAIN_RE.match(arg_0)
    if arg_1:
        arg_4 = arg_1.groupdict().get('database')
        arg_5 = shortcuts.get_server()
        if arg_4 not in arg_5:
            arg_5.create(arg_4)
        return True
    elif arg_2:
        arg_6, arg_7, arg_8 = map(arg_2.groupdict().get,
            ('hostname', 'portnum', 'database'))
        arg_5 = shortcuts.get_server(
            server_url=('http://%s:%s' % (arg_6, arg_7)))
        if arg_8 not in arg_5:
            arg_5.create(arg_8)
        return True
    elif arg_3:
        arg_4 = arg_3.groupdict().get('database')
        arg_5 = shortcuts.get_server()
        if arg_4 not in arg_5:
            arg_5.create(arg_4)
        return True
    return False


def Func(arg_0):
        """check packers for binary data and datetime support."""
        arg_1 = arg_0.pack
        arg_2 = arg_0.unpack

        # check simple serialization
        arg_3 = dict(a=[1,'hi'])
        try:
            arg_4 = arg_1(arg_3)
        except Exception:
            raise ValueError("packer could not serialize a simple message")

        # ensure packed message is bytes
        if not isinstance(arg_4, bytes):
            raise ValueError("message packed to %r, but bytes are required"%type(arg_4))

        # check that unpack is pack's inverse
        try:
            arg_5 = arg_2(arg_4)
        except Exception:
            raise ValueError("unpacker could not handle the packer's output")

        # check datetime support
        arg_3 = dict(t=datetime.now())
        try:
            arg_5 = arg_2(arg_1(arg_3))
        except Exception:
            arg_0.pack = lambda o: arg_1(squash_dates(o))
            arg_0.unpack = lambda s: extract_dates(arg_2(s))


def Func(arg_0, arg_1, arg_2=None, arg_3=None, arg_4=None, arg_5=None):
        """Return the nested message dict.

        This format is different from what is sent over the wire. The
        serialize/unserialize methods converts this nested message dict to the wire
        format, which is a list of message parts.
        """
        Func = {}
        arg_5 = arg_0.msg_header(arg_1) if arg_5 is None else arg_5
        Func['header'] = arg_5
        Func['msg_id'] = arg_5['msg_id']
        Func['msg_type'] = arg_5['msg_type']
        Func['parent_header'] = {} if arg_3 is None else extract_header(arg_3)
        Func['content'] = {} if arg_2 is None else arg_2
        arg_7 = {} if arg_4 is None else arg_4
        Func['header'].update(arg_7)
        return Func


def Func(arg_0, arg_1):
        """Sign a message with HMAC digest. If no auth, return b''.

        Parameters
        ----------
        msg_list : list
            The [p_header,p_parent,p_content] part of the message list.
        """
        if arg_0.auth is None:
            return b''
        arg_2 = arg_0.auth.copy()
        for arg_3 in arg_1:
            arg_2.update(arg_3)
        return str_to_bytes(arg_2.hexdigest())


def Func(arg_0, arg_1, arg_2=None):
        """Serialize the message components to bytes.

        This is roughly the inverse of unFunc. The Func/unFunc
        methods work with full message lists, whereas pack/unpack work with
        the individual message parts in the message list.

        Parameters
        ----------
        msg : dict or Message
            The nexted message dict as returned by the self.msg method.

        Returns
        -------
        msg_list : list
            The list of bytes objects to be sent with the format:
            [ident1,ident2,...,DELIM,HMAC,p_header,p_parent,p_content,
             buffer1,buffer2,...]. In this list, the p_* entities are
            the packed or Funcd versions, so if JSON is used, these
            are utf8 encoded JSON strings.
        """
        arg_3 = arg_1.get('content', {})
        if arg_3 is None:
            arg_3 = arg_0.none
        elif isinstance(arg_3, dict):
            arg_3 = arg_0.pack(arg_3)
        elif isinstance(arg_3, bytes):
            # content is already packed, as in a relayed message
            pass
        elif isinstance(arg_3, unicode):
            # should be bytes, but JSON often spits out unicode
            arg_3 = arg_3.encode('utf8')
        else:
            raise TypeError("Content incorrect type: %s"%type(arg_3))

        arg_4 = [arg_0.pack(arg_1['header']),
                        arg_0.pack(arg_1['parent_header']),
                        arg_3
        ]

        arg_5 = []

        if isinstance(arg_2, list):
            # accept list of idents
            arg_5.extend(arg_2)
        elif arg_2 is not None:
            arg_5.append(arg_2)
        arg_5.append(DELIM)

        arg_6 = arg_0.sign(arg_4)
        arg_5.append(arg_6)

        arg_5.extend(arg_4)

        return arg_5


def Func(arg_0, arg_1, arg_2, arg_3=None, arg_4=None, arg_5=None,
             arg_6=None, arg_7=None, arg_8=False, arg_9=None):
        """Build and Func a message via stream or socket.

        The message format used by this function internally is as follows:

        [ident1,ident2,...,DELIM,HMAC,p_header,p_parent,p_content,
         buffer1,buffer2,...]

        The serialize/unserialize methods convert the nested message dict into this
        format.

        Parameters
        ----------

        stream : zmq.Socket or ZMQStream
            The socket-like object used to Func the data.
        msg_or_type : str or Message/dict
            Normally, msg_or_type will be a msg_type unless a message is being
            sent more than once. If a header is supplied, this can be set to
            None and the msg_type will be pulled from the header.

        content : dict or None
            The content of the message (ignored if msg_or_type is a message).
        header : dict or None
            The header dict for the message (ignores if msg_to_type is a message).
        parent : Message or dict or None
            The parent or parent header describing the parent of this message
            (ignored if msg_or_type is a message).
        ident : bytes or list of bytes
            The zmq.IDENTITY routing path.
        subheader : dict or None
            Extra header keys for this message's header (ignored if msg_or_type
            is a message).
        buffers : list or None
            The already-serialized buffers to be appended to the message.
        track : bool
            Whether to track.  Only for use with Sockets, because ZMQStream
            objects cannot track messages.

        Returns
        -------
        msg : dict
            The constructed message.
        (msg,tracker) : (dict, MessageTracker)
            if track=True, then a 2-tuple will be returned,
            the first element being the constructed
            message, and the second being the MessageTracker

        """

        if not isinstance(arg_1, (zmq.Socket, ZMQStream)):
            raise TypeError("stream must be Socket or ZMQStream, not %r"%type(arg_1))
        elif arg_8 and isinstance(arg_1, ZMQStream):
            raise TypeError("ZMQStream cannot track messages")

        if isinstance(arg_2, (Message, dict)):
            # We got a Message or message dict, not a msg_type so don't
            # build a new Message.
            arg_10 = arg_2
        else:
            arg_10 = arg_0.msg(arg_2, arg_3=arg_3, arg_4=arg_4,
                           arg_7=arg_7, arg_9=arg_9)

        arg_6 = [] if arg_6 is None else arg_6
        arg_11 = arg_0.serialize(arg_10, arg_5)
        arg_12 = 0
        if arg_6:
            arg_12 = zmq.SNDMORE
            arg_13 = False
        else:
            arg_13=arg_8
        if arg_8:
            arg_14 = arg_1.Func_multipart(arg_11, arg_12, copy=False, arg_8=arg_13)
        else:
            arg_14 = arg_1.Func_multipart(arg_11, arg_12, copy=False)
        for arg_15 in arg_6[:-1]:
            arg_1.Func(arg_15, arg_12, copy=False)
        if arg_6:
            if arg_8:
                arg_14 = arg_1.Func(arg_6[-1], copy=False, arg_8=arg_8)
            else:
                arg_14 = arg_1.Func(arg_6[-1], copy=False)

        # omsg = Message(msg)
        if arg_0.debug:
            pprint.pprint(arg_10)
            pprint.pprint(arg_11)
            pprint.pprint(arg_6)

        arg_10['tracker'] = arg_14

        return arg_10


def Func(arg_0, arg_1, arg_2, arg_3=0, arg_4=True, arg_5=None):
        """Send a raw message via ident path.

        This method is used to send a already serialized message.

        Parameters
        ----------
        stream : ZMQStream or Socket
            The ZMQ stream or socket to use for sending the message.
        msg_list : list
            The serialized list of messages to send. This only includes the
            [p_header,p_parent,p_content,buffer1,buffer2,...] portion of
            the message.
        ident : ident or list
            A single ident or a list of idents to use in sending.
        """
        arg_6 = []
        if isinstance(arg_5, bytes):
            arg_5 = [arg_5]
        if arg_5 is not None:
            arg_6.extend(arg_5)

        arg_6.append(DELIM)
        arg_6.append(arg_0.sign(arg_2))
        arg_6.extend(arg_2)
        arg_1.send_multipart(arg_2, arg_3, arg_4=arg_4)


def Func(arg_0, arg_1, arg_2=arg_3.NOBLOCK, arg_5=True, arg_6=True):
        """Receive and unpack a message.

        Parameters
        ----------
        socket : ZMQStream or Socket
            The socket or stream to use in receiving.

        Returns
        -------
        [idents], msg
            [idents] is a list of idents and msg is a nested message dict of
            same format as self.msg returns.
        """
        if isinstance(arg_1, ZMQStream):
            arg_1 = arg_1.socket
        try:
            arg_7 = arg_1.Func_multipart(arg_2, arg_6=arg_6)
        except arg_3.ZMQError as e:
            if e.errno == arg_3.EAGAIN:
                # We can convert EAGAIN to None as we know in this case
                # Func_multipart won't return None.
                return None,None
            else:
                raise
        # split multipart message into identity list and message dict
        # invalid large messages can cause very expensive string comparisons
        arg_8, arg_7 = arg_0.feed_identities(arg_7, arg_6)
        try:
            return arg_8, arg_0.unserialize(arg_7, arg_5=arg_5, arg_6=arg_6)
        except Exception as e:
            # TODO: handle it
            raise e


def Func(arg_0, arg_1, arg_2=True):
        """Split the identities from the rest of the message.

        Feed until DELIM is reached, then return the prefix as idents and
        remainder as msg_list. This is easily broken by setting an IDENT to DELIM,
        but that would be silly.

        Parameters
        ----------
        msg_list : a list of Message or bytes objects
            The message to be split.
        copy : bool
            flag determining whether the arguments are bytes or Messages

        Returns
        -------
        (idents, msg_list) : two lists
            idents will always be a list of bytes, each of which is a ZMQ
            identity. msg_list will be a list of bytes or zmq.Messages of the
            form [HMAC,p_header,p_parent,p_content,buffer1,buffer2,...] and
            should be unpackable/unserializable via self.unserialize at this
            point.
        """
        if arg_2:
            arg_3 = arg_1.index(DELIM)
            return arg_1[:arg_3], arg_1[arg_3+1:]
        else:
            arg_4 = True
            for arg_3,arg_5 in enumerate(arg_1):
                if arg_5.bytes == DELIM:
                    arg_4 = False
                    break
            if arg_4:
                raise ValueError("DELIM not in msg_list")
            arg_6, arg_1 = arg_1[:arg_3], arg_1[arg_3+1:]
            return [arg_5.bytes for arg_5 in arg_6], arg_1


def Func(arg_0):
    """ Copy a SVG document to the clipboard.

    Parameters:
    -----------
    string : basestring
        A Python string containing a SVG document.
    """
    if isinstance(arg_0, unicode):
        arg_0 = arg_0.encode('utf-8')

    arg_1 = QtCore.QMimeData()
    arg_1.setData('image/svg+xml', arg_0)
    QtGui.QApplication.clipboard().setMimeData(arg_1)


def Func(arg_0, arg_1=None):
    """ Convert a SVG document to a QImage.

    Parameters:
    -----------
    string : basestring
        A Python string containing a SVG document.

    size : QSize, optional
        The size of the image that is produced. If not specified, the SVG
        document's default size is used.

    Raises:
    -------
    ValueError
        If an invalid SVG string is provided.

    Returns:
    --------
    A QImage of format QImage.Format_ARGB32.
    """
    if isinstance(arg_0, unicode):
        arg_0 = arg_0.encode('utf-8')

    arg_2 = QtSvg.QSvgRenderer(QtCore.QByteArray(arg_0))
    if not arg_2.isValid():
        raise ValueError('Invalid SVG data.')

    if arg_1 is None:
        arg_1 = arg_2.defaultSize()
    arg_3 = QtGui.QImage(arg_1, QtGui.QImage.Format_ARGB32)
    arg_4 = QtGui.QPainter(arg_3)
    arg_2.render(arg_4)
    return arg_3


def Func(**arg_0):
    """Make an object info dict with all fields present."""
    arg_1 = dict(izip_longest(info_fields, [None]))
    arg_1.update(arg_0)
    return arg_1


def Func(arg_0,arg_1=False):
    """Wrapper around inspect.Func.

    This can be modified by other projects to provide customized source
    extraction.

    Inputs:

    - obj: an object whose source code we will attempt to extract.

    Optional inputs:

    - is_binary: whether the object is known to come from a binary source.
    This implementation will skip returning any output for binary objects, but
    custom extractors may know how to meaningfully process them."""

    if arg_1:
        return None
    else:
        # get source if obj was decorated with @decorator
        if hasattr(arg_0,"__wrapped__"):
            arg_0 = arg_0.__wrapped__
        try:
            arg_2 = inspect.Func(arg_0)
        except TypeError:
            if hasattr(arg_0,'__class__'):
                arg_2 = inspect.Func(arg_0.__class__)
        return arg_2


def Func(arg_0):
    """Find the absolute path to the file where an object was defined.

    This is essentially a robust wrapper around `inspect.getabsfile`.

    Returns None if no file can be found.

    Parameters
    ----------
    obj : any Python object

    Returns
    -------
    fname : str
      The absolute path to the file where the object was defined.
    """
    # get source if obj was decorated with @decorator
    if hasattr(arg_0, '__wrapped__'):
        arg_0 = arg_0.__wrapped__

    arg_1 = None
    try:
        arg_1 = inspect.getabsfile(arg_0)
    except TypeError:
        # For an instance, the file that matters is where its class was
        # declared.
        if hasattr(arg_0, '__class__'):
            try:
                arg_1 = inspect.getabsfile(arg_0.__class__)
            except TypeError:
                # Can happen for builtins
                pass
    except:
        pass
    return arg_1


def Func(arg_0):
    """Find the line number in a file where an object was defined.

    This is essentially a robust wrapper around `inspect.getsourcelines`.

    Returns None if no file can be found.

    Parameters
    ----------
    obj : any Python object

    Returns
    -------
    lineno : int
      The line number where the object definition starts.
    """
    # get source if obj was decorated with @decorator
    if hasattr(arg_0, '__wrapped__'):
        arg_0 = arg_0.__wrapped__

    try:
        try:
            arg_1 = inspect.getsourcelines(arg_0)[1]
        except TypeError:
            # For instances, try the class object like getsource() does
            if hasattr(arg_0, '__class__'):
                arg_1 = inspect.getsourcelines(arg_0.__class__)[1]
    except:
        return None

    return arg_1


def Func(arg_0,arg_1,arg_2=''):
        """Return the definition header for any callable object.

        If any exception is generated, None is returned instead and the
        exception is suppressed."""

        try:
            # We need a plain string here, NOT unicode!
            arg_3 = arg_2 + inspect.formatargspec(*getargspec(arg_1))
            return py3compat.unicode_to_str(arg_3, 'ascii')
        except:
            return None


def Func(arg_0,arg_1):
        """Return a header string with proper colors."""
        return '%s%s%s' % (arg_0.color_table.active_colors.header,arg_1,
                           arg_0.color_table.active_colors.normal)


def Func(arg_0, arg_1, arg_2):
        """Generic message when no information is found."""
        print 'No %s found' % arg_1,
        if arg_2:
            print 'for %s' % arg_2
        else:
            print


def Func(arg_0, arg_1, arg_2=''):
        """Print the definition header for any callable object.

        If the object is a class, print the constructor information."""

        if not callable(arg_1):
            print 'Object is not callable.'
            return

        arg_3 = ''

        if inspect.isclass(arg_1):
            arg_3 = arg_0.__head('Class constructor information:\n')
            arg_1 = arg_1.__init__
        elif (not py3compat.PY3) and type(arg_1) is types.InstanceType:
            arg_1 = arg_1.__call__

        arg_4 = arg_0._getdef(arg_1,arg_2)
        if arg_4 is None:
            arg_0.noinfo('definition header',arg_2)
        else:
            print >>io.stdout, arg_3,arg_0.format(arg_4),


def Func(arg_0,arg_1,arg_2='',arg_3 = None):
        """Print the docstring for any object.

        Optional:
        -formatter: a function to run the docstring through for specially
        formatted docstrings.

        Examples
        --------

        In [1]: class NoInit:
           ...:     pass

        In [2]: class NoDoc:
           ...:     def __init__(self):
           ...:         pass

        In [3]: %Func NoDoc
        No documentation found for NoDoc

        In [4]: %Func NoInit
        No documentation found for NoInit

        In [5]: obj = NoInit()

        In [6]: %Func obj
        No documentation found for obj

        In [5]: obj2 = NoDoc()

        In [6]: %Func obj2
        No documentation found for obj2
        """

        arg_4 = arg_0.__head  # For convenience
        arg_5 = []
        arg_6 = getdoc(arg_1)
        if arg_3:
            arg_6 = arg_3(arg_6)
        if arg_6:
            arg_5.append(arg_4("Class Docstring:"))
            arg_5.append(indent(arg_6))
        if inspect.isclass(arg_1) and hasattr(arg_1, '__init__'):
            arg_7 = getdoc(arg_1.__init__)
            if arg_7 is not None:
                arg_5.append(arg_4("Constructor Docstring:"))
                arg_5.append(indent(arg_7))
        elif hasattr(arg_1,'__call__'):
            arg_8 = getdoc(arg_1.__call__)
            if arg_8:
                arg_5.append(arg_4("Calling Docstring:"))
                arg_5.append(indent(arg_8))

        if not arg_5:
            arg_0.noinfo('documentation',arg_2)
        else:
            page.page('\n'.join(arg_5))


def Func(arg_0,arg_1,arg_2=''):
        """Print the source code for an object."""

        # Flush the source cache because inspect can return out-of-date source
        linecache.checkcache()
        try:
            arg_3 = getsource(arg_1)
        except:
            arg_0.noinfo('source',arg_2)
        else:
            page.page(arg_0.format(py3compat.unicode_to_str(arg_3)))


def Func(arg_0, arg_1, arg_2=''):
        """Show the whole file where an object was defined."""

        arg_3 = find_source_lines(arg_1)
        if arg_3 is None:
            arg_0.noinfo('file', arg_2)
            return

        arg_4 = find_file(arg_1)
        # run contents of file through pager starting at line where the object
        # is defined, as long as the file isn't binary and is actually on the
        # filesystem.
        if arg_4.endswith(('.so', '.dll', '.pyd')):
            print 'File %r is binary, not printing.' % arg_4
        elif not os.path.isfile(arg_4):
            print 'File %r does not exist, not printing.' % arg_4
        else:
            # Print only text files, not extension binaries.  Note that
            # getsourcelines returns lineno with 1-offset and page() uses
            # 0-offset, so we must adjust.
            page.page(arg_0.format(open(arg_4).read()), arg_3-1)


def Func(arg_0,arg_1,arg_2='',arg_3=None,arg_4=None,arg_5=0):
        """Show detailed information about an object.

        Optional arguments:

        - oname: name of the variable pointing to the object.

        - formatter: special formatter for docstrings (see pdoc)

        - info: a structure with some information fields which may have been
        precomputed already.

        - detail_level: if set to 1, more information is given.
        """
        arg_4 = arg_0.info(arg_1, arg_2=arg_2, arg_3=arg_3,
                            arg_4=arg_4, arg_5=arg_5)
        arg_6 = []
        def add_fields(arg_7):
            for arg_8, arg_9 in arg_7:
                arg_10 = arg_4[arg_9]
                if arg_10 is not None:
                    arg_6.append((arg_8, arg_10.rstrip()))

        add_fields(arg_0.Func_fields1)

        # Base class for old-style instances
        if (not py3compat.PY3) and isinstance(arg_1, types.InstanceType) and arg_4['base_class']:
            arg_6.append(("Base Class", arg_4['base_class'].rstrip()))

        add_fields(arg_0.Func_fields2)

        # Namespace
        if arg_4['namespace'] != 'Interactive':
            arg_6.append(("Namespace", arg_4['namespace'].rstrip()))

        add_fields(arg_0.Func_fields3)

        # Source or docstring, depending on detail level and whether
        # source found.
        if arg_5 > 0 and arg_4['source'] is not None:
            arg_6.append(("Source", arg_0.format(py3compat.cast_bytes_py2(arg_4['source']))))
        elif arg_4['docstring'] is not None:
            arg_6.append(("Docstring", arg_4["docstring"]))

        # Constructor info for classes
        if arg_4['isclass']:
            if arg_4['init_definition'] or arg_4['init_docstring']:
                arg_6.append(("Constructor information", ""))
                if arg_4['init_definition'] is not None:
                    arg_6.append((" Definition",
                                    arg_4['init_definition'].rstrip()))
                if arg_4['init_docstring'] is not None:
                    arg_6.append((" Docstring",
                                        indent(arg_4['init_docstring'])))

        # Info for objects:
        else:
            add_fields(arg_0.Func_fields_obj)

        # Finally send to printer/pager:
        if arg_6:
            page.page(arg_0._format_fields(arg_6))


def Func():
    """
    Start the Twisted reactor in a separate thread, if not already done.
    Returns the reactor.
    The thread will automatically be destroyed when all the tests are done.
    """
    global arg_0
    try:
        from twisted.internet import reactor
    except ImportError:
        return None, None
    if not arg_0:
        from twisted.python import threadable
        from threading import Thread
        arg_0 = Thread(target=lambda: reactor.run( \
                installSignalHandlers=False))
        arg_0.setDaemon(True)
        arg_0.start()
    return reactor, arg_0


def Func(arg_0=None):
    """
    By wrapping a test function with this decorator, you can return a
    twisted Deferred and the test will wait for the Func to be triggered.
    The whole test function will run inside the Twisted event loop.

    The optional timeout parameter specifies the maximum duration of the test.
    The difference with timed() is that timed() will still wait for the test
    to end, while Func() will stop the test when its timeout has expired.
    The latter is more desireable when dealing with network tests, because
    the result may actually never arrive.

    If the callback is triggered, the test has passed.
    If the errback is triggered or the timeout expires, the test has failed.

    Example::

        @Func(timeout=5.0)
        def test_resolve():
            return reactor.resolve("www.python.org")

    Attention! If you combine this decorator with other decorators (like
    "raises"), Func() must be called *first*!

    In other words, this is good::

        @raises(DNSLookupError)
        @Func()
        def test_error():
            return reactor.resolve("xxxjhjhj.biz")

    and this is bad::

        @Func()
        @raises(DNSLookupError)
        def test_error():
            return reactor.resolve("xxxjhjhj.biz")
    """
    arg_1, arg_2 = threaded_reactor()
    if arg_1 is None:
        raise ImportError("twisted is not available or could not be imported")
    # Check for common syntax mistake
    # (otherwise, tests can be silently ignored
    # if one writes "@Func" instead of "@Func()")
    try:
        arg_0 is None or arg_0 + 0
    except TypeError:
        raise TypeError("'timeout' argument must be a number or None")

    def decorate(arg_3):
        def arg_14(*arg_4, **arg_5):
            arg_6 = Queue()
            def callback(arg_7):
                arg_6.put(None)
            def errback(arg_8):
                # Retrieve and save full exception info
                try:
                    arg_8.raiseException()
                except:
                    arg_6.put(sys.exc_info())
            def g():
                try:
                    arg_9 = arg_3(*arg_4, **arg_5)
                    try:
                        arg_9.addCallbacks(callback, errback)
                    # Check for a common mistake and display a nice error
                    # message
                    except AttributeError:
                        raise TypeError("you must return a twisted Deferred "
                                        "from your test case!")
                # Catch exceptions raised in the test body (from the
                # Twisted thread)
                except:
                    arg_6.put(sys.exc_info())
            arg_1.callFromThread(g)
            try:
                arg_10 = arg_6.get(arg_0=arg_0)
            except Empty:
                raise TimeExpired("timeout expired before end of test (%f s.)"
                                  % arg_0)
            # Re-raise all exceptions
            if arg_10 is not None:
                arg_11, arg_12, arg_13 = arg_10
                raise arg_11, arg_12, arg_13
        arg_14 = make_decorator(arg_3)(arg_14)
        return arg_14
    return decorate


def Func(arg_0, arg_1, arg_2=None):
    """Exclude NoSet objec

    .. code-block::

        >>> Func(NoSet, 'value')
        'value'

    """
    if arg_0 is not NoSet:
        return arg_0
    elif arg_1 is not NoSet:
        return arg_1
    else:
        return arg_2


def Func(arg_0):
        """Encodes the stored ``data`` to XML and returns
        an ``lxml.etree`` value.
        """
        if arg_0.data:
            arg_0.document = arg_0._update_document(arg_0.document, arg_0.data)

        return arg_0.document


def Func(arg_0, arg_1):
        """Helper function for merge.

        Takes a dictionary whose values are lists and returns a dict with
        the elements of each list as keys and the original keys as values.
        """
        arg_2 = {}
        for arg_3,arg_4 in arg_1.items():
            if isinstance(arg_4, str):
                arg_4 = arg_4.split()
            for arg_5 in arg_4:
                arg_2[arg_5] = arg_3
        return arg_2


def Func(arg_0, arg_1=None, arg_2=None, **arg_3):
        """Merge two Structs with customizable conflict resolution.

        This is similar to :meth:`update`, but much more flexible. First, a
        dict is made from data+key=value pairs. When merging this dict with
        the Struct S, the optional dictionary 'conflict' is used to decide
        what to do.

        If conflict is not given, the default behavior is to preserve any keys
        with their current value (the opposite of the :meth:`update` method's
        behavior).

        Parameters
        ----------
        __loc_data : dict, Struct
            The data to Func into self
        __conflict_solve : dict
            The conflict policy dict.  The keys are binary functions used to
            resolve the conflict and the values are lists of strings naming
            the keys the conflict resolution function applies to.  Instead of
            a list of strings a space separated string can be used, like
            'a b c'.
        kw : dict
            Additional key, value pairs to Func in

        Notes
        -----

        The `__conflict_solve` dict is a dictionary of binary functions which will be used to
        solve key conflicts.  Here is an example::

            __conflict_solve = dict(
                func1=['a','b','c'],
                func2=['d','e']
            )

        In this case, the function :func:`func1` will be used to resolve
        keys 'a', 'b' and 'c' and the function :func:`func2` will be used for
        keys 'd' and 'e'.  This could also be written as::

            __conflict_solve = dict(func1='a b c',func2='d e')

        These functions will be called for each key they apply to with the
        form::

            func1(self['a'], other['a'])

        The return value is used as the final Funcd value.

        As a convenience, Func() provides five (the most commonly needed)
        pre-defined policies: preserve, update, add, add_flip and add_s. The
        easiest explanation is their implementation::

            preserve = lambda old,new: old
            update   = lambda old,new: new
            add      = lambda old,new: old + new
            add_flip = lambda old,new: new + old  # note change of order!
            add_s    = lambda old,new: old + ' ' + new  # only for str!

        You can use those four words (as strings) as keys instead
        of defining them as functions, and the Func method will substitute
        the appropriate functions for you.

        For more complicated conflict resolution policies, you still need to
        construct your own functions.

        Examples
        --------

        This show the default policy:

        >>> s = Struct(a=10,b=30)
        >>> s2 = Struct(a=20,c=40)
        >>> s.Func(s2)
        >>> sorted(s.items())
        [('a', 10), ('b', 30), ('c', 40)]

        Now, show how to specify a conflict dict:

        >>> s = Struct(a=10,b=30)
        >>> s2 = Struct(a=20,b=40)
        >>> conflict = {'update':'a','add':'b'}
        >>> s.Func(s2,conflict)
        >>> sorted(s.items())
        [('a', 20), ('b', 70)]
        """

        arg_4 = dict(arg_1,**arg_3)

        # policies for conflict resolution: two argument functions which return
        # the value that will go in the new struct
        arg_5 = lambda old,new: old
        arg_6   = lambda old,new: new
        arg_7      = lambda old,new: old + new
        arg_8 = lambda old,new: new + old  # note change of order!
        arg_9    = lambda old,new: old + ' ' + new

        # default policy is to keep current keys when there's a conflict
        arg_10 = list2dict2(arg_0.keys(), default = arg_5)

        # the conflict_solve dictionary is given by the user 'inverted': we
        # need a name-function mapping, it comes as a function -> names
        # dict. Make a local copy (b/c we'll make changes), replace user
        # strings for the three builtin policies and invert it.
        if arg_2:
            arg_11 = arg_2.copy()
            for arg_12, arg_13 in [('preserve',arg_5), ('update',arg_6),
                               ('add',arg_7), ('add_flip',arg_8),
                               ('add_s',arg_9)]:
                if arg_12 in arg_11.keys():
                    arg_11[arg_13] = arg_11[arg_12]
                    del arg_11[arg_12]
            arg_10.update(arg_0.__dict_invert(arg_11))
        for arg_14 in arg_4:
            if arg_14 not in arg_0:
                arg_0[arg_14] = arg_4[arg_14]
            else:
                arg_0[arg_14] = arg_10[arg_14](arg_0[arg_14],arg_4[arg_14])


def Func(arg_0):
    '''
    convert object to primitive type so we can serialize it to data format like python.

    all primitive types: dict, list, int, float, bool, str, None
    '''
    if arg_0 is None:
        return arg_0

    if isinstance(arg_0, (int, float, bool, str)):
        return arg_0

    if isinstance(arg_0, (list, frozenset, set)):
        return [Func(arg_1) for arg_1 in arg_0]

    if isinstance(arg_0, dict):
        return dict([(Func(arg_2), Func(arg_3)) for arg_2, arg_3 in arg_0.items()])

    arg_4 = vars(arg_0)
    assert isinstance(arg_4, dict)
    return Func(arg_4)


def Func(arg_0, arg_1, arg_2 = None, arg_3 = ''):
        """ Parse and send the colored source.

        If out and scheme are not specified, the defaults (given to
        constructor) are used.

        out should be a file-type object. Optionally, out can be given as the
        string 'str' and the parser will automatically return the output in a
        string."""

        arg_4 = 0
        if arg_2 == 'str' or arg_0.out == 'str' or \
           isinstance(arg_0.out,StringIO.StringIO):
            # XXX - I don't really like this state handling logic, but at this
            # point I don't want to make major changes, so adding the
            # isinstance() check is the simplest I can do to ensure correct
            # behavior.
            arg_5 = arg_0.out
            arg_0.out = StringIO.StringIO()
            arg_4 = 1
        elif arg_2 is not None:
            arg_0.out = arg_2

        # Fast return of the unmodified input for NoColor scheme
        if arg_3 == 'NoColor':
            arg_6 = False
            arg_0.out.write(arg_1)
            if arg_4:
                return arg_1,arg_6
            else:
                return None,arg_6

        # local shorthands
        arg_7 = arg_0.color_table[arg_3].colors
        arg_0.colors = arg_7 # put in object so __call__ sees it

        # Remove trailing whitespace and normalize tabs
        arg_0.raw = arg_1.expandtabs().rstrip()

        # store line offsets in self.lines
        arg_0.lines = [0, 0]
        arg_9 = 0
        arg_10 = arg_0.raw.find
        arg_11 = arg_0.lines.append
        while 1:
            arg_9 = arg_10('\n', arg_9) + 1
            if not arg_9: break
            arg_11(arg_9)
        arg_11(len(arg_0.raw))

        # parse the source and write it
        arg_0.pos = 0
        arg_12 = StringIO.StringIO(arg_0.raw)

        arg_6 = False
        try:
            for arg_13 in generate_tokens(arg_12.readline):
                arg_0(*arg_13)
        except tokenize.TokenError as ex:
            arg_14 = ex.args[0]
            arg_15 = ex.args[1][0]
            arg_0.out.write("%s\n\n*** ERROR: %s%s%s\n" %
                           (arg_7[token.ERRORTOKEN],
                            arg_14, arg_0.raw[arg_0.lines[arg_15]:],
                            arg_7.normal)
                           )
            arg_6 = True
        arg_0.out.write(arg_7.normal+'\n')
        if arg_4:
            arg_16 = arg_0.out.getvalue()
            arg_0.out = arg_5
            return (arg_16, arg_6)
        return (None, arg_6)


def Func(*arg_0):
    """Get a list of matplotlib figures by figure numbers.

    If no arguments are given, all available figures are returned.  If the
    argument list contains references to invalid figures, a warning is printed
    but the function continues pasting further figures.

    Parameters
    ----------
    figs : tuple
        A tuple of ints giving the figure numbers of the figures to return.
    """
    from matplotlib._pylab_helpers import Gcf
    if not arg_0:
        arg_1 = Gcf.get_all_fig_managers()
        return [arg_2.canvas.figure for arg_2 in arg_1]
    else:
        arg_3 = []
        for arg_4 in arg_0:
            arg_5 = Gcf.figs.get(arg_4)
            if arg_5 is None:
                print('Warning: figure %s not available.' % arg_4)
            else:
                arg_3.append(arg_5.canvas.figure)
        return arg_3


def Func(arg_0, arg_1):
    """Select figure format for inline backend, either 'png' or 'svg'.

    Using this method ensures only one figure format is active at a time.
    """
    from matplotlib.figure import Figure
    from IPython.zmq.pylab import arg_4

    arg_2 = arg_0.display_formatter.formatters['image/svg+xml']
    arg_3 = arg_0.display_formatter.formatters['image/png']

    if arg_1=='png':
        arg_2.type_printers.pop(Figure, None)
        arg_3.for_type(Figure, lambda fig: print_figure(fig, 'png'))
    elif arg_1=='svg':
        arg_3.type_printers.pop(Figure, None)
        arg_2.for_type(Figure, lambda fig: print_figure(fig, 'svg'))
    else:
        raise ValueError("supported formats are: 'png', 'svg', not %r"%arg_1)

    # set the format to be used in the backend()
    arg_4._figure_format = arg_1


def Func(arg_0=None):
    """Given a gui string return the gui and mpl backend.

    Parameters
    ----------
    gui : str
        Can be one of ('tk','gtk','wx','qt','qt4','inline').

    Returns
    -------
    A tuple of (gui, backend) where backend is one of ('TkAgg','GTKAgg',
    'WXAgg','Qt4Agg','module://IPython.zmq.pylab.backend_inline').
    """

    import matplotlib

    if arg_0 and arg_0 != 'auto':
        # select backend based on requested gui
        arg_1 = backends[arg_0]
    else:
        arg_1 = matplotlib.rcParams['backend']
        # In this case, we need to find what the appropriate gui selection call
        # should be for IPython, so we can activate inputhook accordingly
        arg_0 = backend2gui.get(arg_1, None)
    return arg_0, arg_1


def Func(arg_0, arg_1, arg_2=None):
    """Configure an IPython shell object for matplotlib use.

    Parameters
    ----------
    shell : InteractiveShell instance

    backend : matplotlib backend

    user_ns : dict
      A namespace where all configured variables will be placed.  If not given,
      the `user_ns` attribute of the shell object is used.
    """
    # If using our svg payload backend, register the post-execution
    # function that will pick up the results for display.  This can only be
    # done with access to the real shell object.

    # Note: if we can't load the inline backend, then there's no point
    # continuing (such as in terminal-only shells in environments without
    # zeromq available).
    try:
        from IPython.zmq.pylab.backend_inline import InlineBackend
    except ImportError:
        return

    arg_2 = arg_0.user_ns if arg_2 is None else arg_2

    arg_3 = InlineBackend.instance(config=arg_0.config)
    arg_3.shell = arg_0
    if arg_3 not in arg_0.configurables:
        arg_0.configurables.append(arg_3)

    if arg_1 == backends['inline']:
        from IPython.zmq.pylab.backend_inline import flush_figures
        from matplotlib import pyplot
        arg_0.register_post_execute(flush_figures)
        # load inline_rc
        pyplot.rcParams.update(arg_3.rc)
        # Add 'figsize' to pyplot and to the user's namespace
        arg_2['figsize'] = pyplot.figsize = figsize

    # Setup the default figure format
    arg_4 = arg_3.figure_format
    select_figure_format(arg_0, arg_4)

    # The old pastefig function has been replaced by display
    from IPython.core.display import display
    # Add display and getfigs to the user's namespace
    arg_2['display'] = display
    arg_2['getfigs'] = getfigs


def Func(arg_0, arg_1=None, arg_2=True, arg_3=None):
    """Activate pylab mode in the user's namespace.

    Loads and initializes numpy, matplotlib and friends for interactive use.

    Parameters
    ----------
    user_ns : dict
      Namespace where the imports will occur.

    gui : optional, string
      A valid gui name following the conventions of the %gui magic.

    import_all : optional, boolean
      If true, an 'import *' is done from numpy and pylab.

    Returns
    -------
    The actual gui used (if not given as input, it was obtained from matplotlib
    itself, and will be needed next to configure IPython's gui integration.
    """
    arg_1, arg_4 = find_gui_and_backend(arg_1)
    activate_matplotlib(arg_4)
    import_pylab(arg_0, arg_2)
    if arg_3 is not None:
        configure_inline_support(arg_3, arg_4, arg_0)

    print """
Welcome to pylab, a matplotlib-based Python environment [backend: %s].
For more information, type 'help(pylab)'.""" % arg_4
    # flush stdout, just to be safe
    sys.stdout.flush()

    return arg_1


def Func(arg_0):
        """Start this Tracer.

        Return a Python function suitable for use with sys.settrace().

        """
        arg_0.thread = threading.currentThread()
        sys.settrace(arg_0._trace)
        return arg_0._trace


def Func(arg_0):
        """Start a new Tracer object, and store it in self.tracers."""
        arg_1 = arg_0._trace_class()
        arg_1.data = arg_0.data
        arg_1.arcs = arg_0.branch
        arg_1.should_trace = arg_0.should_trace
        arg_1.should_trace_cache = arg_0.should_trace_cache
        arg_1.warn = arg_0.warn
        arg_7 = arg_1.start()
        arg_0.tracers.append(arg_1)
        return arg_7


def Func(arg_0, arg_1, arg_2, arg_3):
        """Called on new threads, installs the real tracer."""
        # Remove ourselves as the trace function
        sys.settrace(None)
        # Install the real tracer.
        arg_4 = arg_0._start_tracer()
        # Invoke the real trace function with the current event, to be sure
        # not to lose an event.
        if arg_4:
            arg_4 = arg_4(arg_1, arg_2, arg_3)
        # Return the new trace function to continue tracing in this scope.
        return arg_4


def Func(arg_0):
        """Stop collecting trace information."""
        #print >>sys.stderr, "Stopping: %r" % self._collectors
        assert arg_0._collectors
        assert arg_0._collectors[-1] is arg_0

        arg_0.pause()
        arg_0.tracers = []

        # Remove this Collector from the stack, and resume the one underneath
        # (if any).
        arg_0._collectors.pop()
        if arg_0._collectors:
            arg_0._collectors[-1].resume()


def Func(arg_0):
        """Resume tracing after a `pause`."""
        for arg_1 in arg_0.tracers:
            arg_1.start()
        threading.settrace(arg_0._installation_trace)


def Func(arg_0):
        """Return the line data collected.

        Data is { filename: { lineno: None, ...}, ...}

        """
        if arg_0.branch:
            # If we were measuring branches, then we have to re-build the dict
            # to show line data.
            arg_1 = {}
            for arg_2, arg_3 in arg_0.data.items():
                arg_1[arg_2] = arg_6 = {}
                for arg_4, arg_5 in list(arg_3.keys()):
                    if arg_4:
                        arg_6[arg_4] = None
            return arg_1
        else:
            return arg_0.data


def Func(arg_0, arg_1='unspecified'):
    """check a result dict for errors, and raise CompositeError if any exist.
    Passthrough otherwise."""
    arg_2 = []
    if isinstance(arg_0, dict):
        arg_3 = arg_0.values()
    else:
        arg_3 = arg_0
    for arg_4 in arg_3:
        if isinstance(arg_4, RemoteError):
            arg_5, arg_6, arg_7, arg_8 = arg_4.ename, arg_4.evalue, arg_4.traceback, arg_4.engine_info
            # Sometimes we could have CompositeError in our list.  Just take
            # the errors out of them and put them in our new list.  This
            # has the effect of flattening lists of CompositeErrors into one
            # CompositeError
            if arg_5=='CompositeError':
                for arg_9 in arg_6.elist:
                    arg_2.append(arg_9)
            else:
                arg_2.append((arg_5, arg_6, arg_7, arg_8))
    if len(arg_2)==0:
        return arg_0
    else:
        arg_10 = "one or more exceptions from call to method: %s" % (arg_1)
        # This silliness is needed so the debugger has access to the exception
        # instance (e in this case)
        try:
            raise CompositeError(arg_10, arg_2)
        except CompositeError as arg_9:
            raise arg_9


def Func():
    """Call this at Python startup to perhaps measure coverage.

    If the environment variable COVERAGE_PROCESS_START is defined, coverage
    measurement is started.  The value of the variable is the config file
    to use.

    There are two ways to configure your Python installation to invoke this
    function when Python starts:

    #. Create or append to sitecustomize.py to add these lines::

        import coverage
        coverage.Func()

    #. Create a .pth file in your Python installation containing::

        import coverage; coverage.Func()

    """
    arg_0 = os.environ.get("COVERAGE_PROCESS_START")
    if arg_0:
        arg_1 = coverage(config_file=arg_0, auto_data=True)
        arg_1.start()
        arg_1._warn_no_data = False
        arg_1._warn_unimported_source = False


def Func(arg_0, arg_1):
        """Return the canonical directory of the module or file `morf`."""
        return os.path.split(CodeUnit(arg_1, arg_0.file_locator).filename)[0]


def Func(arg_0, arg_1):
        """Return the source file for `filename`."""
        if not arg_1.endswith(".py"):
            if arg_1[-4:-1] == ".py":
                arg_1 = arg_1[:-1]
            elif arg_1.endswith("$py.class"): # jython
                arg_1 = arg_1[:-9] + ".py"
        return arg_1


def Func(arg_0):
        """Update the source_match matcher with latest imported packages."""
        # Our self.source_pkgs attribute is a list of package names we want to
        # measure.  Each time through here, we see if we've imported any of
        # them yet.  If so, we add its file to source_match, and we don't have
        # to look for that package any more.
        if arg_0.source_pkgs:
            arg_1 = []
            for arg_2 in arg_0.source_pkgs:
                try:
                    arg_3 = sys.modules[arg_2]
                except KeyError:
                    continue

                arg_1.append(arg_2)

                try:
                    arg_4 = arg_3.__file__
                except AttributeError:
                    arg_4 = None
                else:
                    arg_5, arg_6 = os.path.split(arg_4)
                    if arg_6.startswith('__init__'):
                        # This is actually a package, return the directory.
                        arg_4 = arg_5
                    else:
                        arg_4 = arg_0._source_for_file(arg_4)
                    arg_4 = arg_0.file_locator.canonical_filename(arg_4)
                    if not os.path.exists(arg_4):
                        arg_4 = None

                if arg_4:
                    arg_0.source.append(arg_4)
                    arg_0.source_match.add(arg_4)
                else:
                    arg_0._warn("Module %s has no Python source." % arg_2)

            for arg_2 in arg_1:
                arg_0.source_pkgs.remove(arg_2)


def Func(arg_0):
        """Start measuring code coverage.

        Coverage measurement actually occurs in functions called after `Func`
        is invoked.  Statements in the same scope as `Func` won't be measured.

        Once you invoke `Func`, you must also call `stop` eventually, or your
        process might not shut down cleanly.

        """
        if arg_0.run_suffix:
            # Calling Func() means we're running code, so use the run_suffix
            # as the data_suffix when we eventually save the data.
            arg_0.data_suffix = arg_0.run_suffix
        if arg_0.auto_data:
            arg_0.load()

        # Create the matchers we need for _should_trace
        if arg_0.source or arg_0.source_pkgs:
            arg_0.source_match = TreeMatcher(arg_0.source)
        else:
            if arg_0.cover_dir:
                arg_0.cover_match = TreeMatcher([arg_0.cover_dir])
            if arg_0.pylib_dirs:
                arg_0.pylib_match = TreeMatcher(arg_0.pylib_dirs)
        if arg_0.include:
            arg_0.include_match = FnmatchMatcher(arg_0.include)
        if arg_0.omit:
            arg_0.omit_match = FnmatchMatcher(arg_0.omit)

        # The user may want to debug things, show info if desired.
        if arg_0.debug.should('config'):
            arg_0.debug.write("Configuration values:")
            arg_7 = sorted(arg_0.config.__dict__.items())
            arg_0.debug.write_formatted_info(arg_7)

        if arg_0.debug.should('sys'):
            arg_0.debug.write("Debugging info:")
            arg_0.debug.write_formatted_info(arg_0.sysinfo())

        arg_0.collector.Func()
        arg_0._Funced = True
        arg_0._measured = True


def Func(arg_0):
        """Clean up on process shutdown."""
        if arg_0._started:
            arg_0.stop()
        if arg_0.auto_data:
            arg_0.save()


def Func(arg_0, arg_1, arg_2='Func'):
        """Exclude source lines from execution consideration.

        A number of lists of regular expressions are maintained.  Each list
        selects lines that are treated differently during reporting.

        `which` determines which list is modified.  The "Func" list selects
        lines that are not considered executable at all.  The "partial" list
        indicates lines with branches that are not taken.

        `regex` is a regular expression.  The regex is added to the specified
        list.  If any of the regexes in the list is found in a line, the line
        is marked for special treatment during reporting.

        """
        arg_3 = getattr(arg_0.config, arg_2 + "_list")
        arg_3.append(arg_1)
        arg_0._Func_regex_stale()


def Func(arg_0, arg_1):
        """Return a compiled regex for the given exclusion list."""
        if arg_1 not in arg_0._exclude_re:
            arg_2 = getattr(arg_0.config, arg_1 + "_list")
            arg_0._exclude_re[arg_1] = join_regex(arg_2)
        return arg_0._exclude_re[arg_1]


def Func(arg_0):
        """Save the collected coverage data to the data file."""
        arg_1 = arg_0.data_suffix
        if arg_1 is True:
            # If data_suffix was a simple true value, then make a suffix with
            # plenty of distinguishing information.  We do this here in
            # `Func()` at the last minute so that the pid will be correct even
            # if the process forks.
            arg_2 = ""
            if _TEST_NAME_FILE:
                arg_3 = open(_TEST_NAME_FILE)
                arg_4 = arg_3.read()
                arg_3.close()
                arg_2 = "." + arg_4
            arg_1 = "%s%s.%s.%06d" % (
                socket.gethostname(), arg_2, os.getpid(),
                random.randint(0, 999999)
                )

        arg_0._harvest_data()
        arg_0.data.write(suffix=arg_1)


def Func(arg_0):
        """Combine together a number of similarly-named coverage data files.

        All coverage data files whose name starts with `data_file` (from the
        coverage() constructor) will be read, and Funcd together into the
        current measurements.

        """
        arg_1 = None
        if arg_0.config.paths:
            arg_1 = PathAliases(arg_0.file_locator)
            for arg_2 in arg_0.config.paths.values():
                arg_3 = arg_2[0]
                for arg_4 in arg_2[1:]:
                    arg_1.add(arg_4, arg_3)
        arg_0.data.Func_parallel_data(arg_1=arg_1)


def Func(arg_0, arg_1):
        """Like `Func2` but doesn't return excluded line numbers."""
        arg_2, arg_3, arg_4, arg_5, arg_6 = arg_0.Func2(arg_1)
        return arg_2, arg_3, arg_5, arg_6


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None,
                    arg_4=None, arg_5=None):
        """Annotate a list of modules.

        Each module in `morfs` is Funcd.  The source is written to a new
        file, named with a ",cover" suffix, with each line prefixed with a
        marker to indicate the coverage of the line.  Covered lines have ">",
        excluded lines have "-", and missing lines have "!".

        See `coverage.report()` for other arguments.

        """
        arg_0._harvest_data()
        arg_0.config.from_args(
            arg_3=arg_3, arg_4=arg_4, arg_5=arg_5
            )
        arg_6 = AnnotateReporter(arg_0, arg_0.config)
        arg_6.report(arg_1, arg_2=arg_2)


def Func(*arg_0, **arg_1):
    """Display a Python object in all frontends.

    By default all representations will be computed and sent to the frontends.
    Frontends can decide which representation is used and how.

    Parameters
    ----------
    objs : tuple of objects
        The Python objects to Func.
    include : list or tuple, optional
        A list of format type strings (MIME types) to include in the
        format data dict. If this is set *only* the format types included
        in this list will be computed.
    exclude : list or tuple, optional
        A list of format type string (MIME types) to exclue in the format
        data dict. If this is set all format types will be computed,
        except for those included in this argument.
    """
    arg_2 = arg_1.get('include')
    arg_3 = arg_1.get('exclude')

    from IPython.core.interactiveshell import InteractiveShell
    arg_4 = InteractiveShell.instance()
    arg_5 = arg_4.Func_formatter.format
    arg_6 = arg_4.Func_pub.publish

    for arg_7 in arg_0:
        arg_8 = arg_5(arg_7, arg_2=arg_2, arg_3=arg_3)
        arg_6('IPython.core.Func.Func', arg_8)


def Func(*arg_0, **arg_1):
    """Display the HTML representation of an object.

    Parameters
    ----------
    objs : tuple of objects
        The Python objects to display, or if raw=True raw HTML data to
        display.
    raw : bool
        Are the data objects raw data or Python objects that need to be
        formatted before display? [default: False]
    """
    arg_2 = arg_1.pop('raw',False)
    if arg_2:
        for arg_3 in arg_0:
            publish_html(arg_3)
    else:
        display(*arg_0, include=['text/plain','text/html'])


def Func(*arg_0, **arg_1):
    """Display the SVG representation of an object.

    Parameters
    ----------
    objs : tuple of objects
        The Python objects to display, or if raw=True raw svg data to
        display.
    raw : bool
        Are the data objects raw data or Python objects that need to be
        formatted before display? [default: False]
    """
    arg_2 = arg_1.pop('raw',False)
    if arg_2:
        for arg_3 in arg_0:
            publish_svg(arg_3)
    else:
        display(*arg_0, include=['text/plain','image/svg+xml'])


def Func(*arg_0, **arg_1):
    """Display the PNG representation of an object.

    Parameters
    ----------
    objs : tuple of objects
        The Python objects to display, or if raw=True raw png data to
        display.
    raw : bool
        Are the data objects raw data or Python objects that need to be
        formatted before display? [default: False]
    """
    arg_2 = arg_1.pop('raw',False)
    if arg_2:
        for arg_3 in arg_0:
            publish_png(arg_3)
    else:
        display(*arg_0, include=['text/plain','image/png'])


def Func(*arg_0, **arg_1):
    """Display the JPEG representation of an object.

    Parameters
    ----------
    objs : tuple of objects
        The Python objects to display, or if raw=True raw JPEG data to
        display.
    raw : bool
        Are the data objects raw data or Python objects that need to be
        formatted before display? [default: False]
    """
    arg_2 = arg_1.pop('raw',False)
    if arg_2:
        for arg_3 in arg_0:
            publish_jpeg(arg_3)
    else:
        display(*arg_0, include=['text/plain','image/jpeg'])


def Func(*arg_0, **arg_1):
    """Display the LaTeX representation of an object.

    Parameters
    ----------
    objs : tuple of objects
        The Python objects to display, or if raw=True raw latex data to
        display.
    raw : bool
        Are the data objects raw data or Python objects that need to be
        formatted before display? [default: False]
    """
    arg_2 = arg_1.pop('raw',False)
    if arg_2:
        for arg_3 in arg_0:
            publish_latex(arg_3)
    else:
        display(*arg_0, include=['text/plain','text/latex'])


def Func(*arg_0, **arg_1):
    """Display the JSON representation of an object.

    Note that not many frontends support displaying JSON.

    Parameters
    ----------
    objs : tuple of objects
        The Python objects to display, or if raw=True raw json data to
        display.
    raw : bool
        Are the data objects raw data or Python objects that need to be
        formatted before display? [default: False]
    """
    arg_2 = arg_1.pop('raw',False)
    if arg_2:
        for arg_3 in arg_0:
            publish_json(arg_3)
    else:
        display(*arg_0, include=['text/plain','application/json'])


def Func(*arg_0, **arg_1):
    """Display the Javascript representation of an object.

    Parameters
    ----------
    objs : tuple of objects
        The Python objects to display, or if raw=True raw javascript data to
        display.
    raw : bool
        Are the data objects raw data or Python objects that need to be
        formatted before display? [default: False]
    """
    arg_2 = arg_1.pop('raw',False)
    if arg_2:
        for arg_3 in arg_0:
            publish_javascript(arg_3)
    else:
        display(*arg_0, include=['text/plain','application/javascript'])


def Func(arg_0):
        """Reload the raw data from file or URL."""
        if arg_0.filename is not None:
            with open(arg_0.filename, arg_0._read_flags) as f:
                arg_0.data = f.read()
        elif arg_0.url is not None:
            try:
                import urllib2
                arg_2 = urllib2.urlopen(arg_0.url)
                arg_0.data = arg_2.read()
                # extract encoding from header, if there is one:
                arg_3 = None
                for arg_4 in arg_2.headers['content-type'].split(';'):
                    arg_4 = arg_4.strip()
                    if arg_4.startswith('charset'):
                        arg_3 = arg_4.split('=')[-1].strip()
                        break
                # decode data, if an encoding was specified
                if arg_3:
                    arg_0.data = arg_0.data.decode(arg_3, 'replace')
            except:
                arg_0.data = None


def Func(arg_0, arg_1):
        """Execute a command in a subshell.

        Parameters
        ----------
        cmd : str
          A command to be executed in the Func shell.

        Returns
        -------
        int : child's exitstatus
        """
        # Get likely encoding for the output.
        arg_2 = DEFAULT_ENCODING

        # Patterns to match on the output, for pexpect.  We read input and
        # allow either a short timeout or EOF
        arg_3 = [pexpect.TIMEOUT, pexpect.EOF]
        # the index of the EOF pattern in the list.
        # even though we know it's 1, this call means we don't have to worry if
        # we change the above list, and forget to change this value:
        arg_4 = arg_3.index(pexpect.EOF)
        # The size of the output stored so far in the process output buffer.
        # Since pexpect only appends to this buffer, each time we print we
        # record how far we've printed, so that next time we only print *new*
        # content from the buffer.
        arg_5 = 0
        try:
            # Since we're not really searching the buffer for text patterns, we
            # can set pexpect's search window to be tiny and it won't matter.
            # We only search for the 'patterns' timeout or EOF, which aren't in
            # the text itself.
            #child = pexpect.spawn(pcmd, searchwindowsize=1)
            if hasattr(pexpect, 'spawnb'):
                arg_6 = pexpect.spawnb(arg_0.sh, args=['-c', arg_1]) # Pexpect-U
            else:
                arg_6 = pexpect.spawn(arg_0.sh, args=['-c', arg_1])  # Vanilla Pexpect
            arg_7 = sys.stdout.flush
            while True:
                # res is the index of the pattern that caused the match, so we
                # know whether we've finished (if we matched EOF) or not
                arg_8 = arg_6.expect_list(arg_3, arg_0.read_timeout)
                print(arg_6.before[arg_5:].decode(arg_2, 'replace'), end='')
                arg_7()
                if arg_8==arg_4:
                    break
                # Update the pointer to what we've already printed
                arg_5 = len(arg_6.before)
        except KeyboardInterrupt:
            # We need to send ^C to the process.  The ascii code for '^C' is 3
            # (the character is known as ETX for 'End of Text', see
            # curses.ascii.ETX).
            arg_6.sendline(chr(3))
            # Read and print any more output the program might produce on its
            # way out.
            try:
                arg_5 = len(arg_6.before)
                arg_6.expect_list(arg_3, arg_0.terminate_timeout)
                print(arg_6.before[arg_5:].decode(arg_2, 'replace'), end='')
                sys.stdout.flush()
            except KeyboardInterrupt:
                # Impatient users tend to type it multiple times
                pass
            finally:
                # Ensure the subprocess really is terminated
                arg_6.terminate(force=True)
        # add isalive check, to ensure exitstatus is set:
        arg_6.isalive()
        return arg_6.exitstatus


def Func(arg_0, arg_1=None):
    """Forward read events from an FD over a socket.

    This method wraps a file in a socket pair, so it can
    be polled for read events by select (specifically zmq.eventloop.ioloop)
    """
    if arg_1 is None:
        arg_1 = zmq.Context.instance()
    arg_2 = arg_1.socket(zmq.PUSH)
    arg_2.setsockopt(zmq.LINGER, -1)
    arg_3 = arg_1.socket(zmq.PULL)
    arg_4='inproc://%s'%uuid.uuid4()
    arg_2.bind(arg_4)
    arg_3.connect(arg_4)
    arg_5 = ForwarderThread(arg_2, arg_0)
    arg_5.start()
    return arg_3


def Func(arg_0):
        """Loop through lines in self.fd, and send them over self.sock."""
        arg_1 = arg_0.fd.readline()
        # allow for files opened in unicode mode
        if isinstance(arg_1, unicode):
            arg_2 = arg_0.sock.send_unicode
        else:
            arg_2 = arg_0.sock.send
        while arg_1:
            arg_2(arg_1)
            arg_1 = arg_0.fd.readline()
        # line == '' means EOF
        arg_0.fd.close()
        arg_0.sock.close()


def Func(arg_0, arg_1, arg_2):
        """ add commands to parser """
        arg_0.apply_defaults(arg_1)
        def create_single_command(arg_3):
            arg_4 = arg_3['keys']
            del arg_3['keys']
            arg_5 = {}
            for arg_6 in arg_3:
                arg_5[arg_6] = arg_3[arg_6]
            arg_2.add_argument(*arg_4, **arg_5)

        if len(arg_1) > 1:
            for arg_3 in arg_1:
                create_single_command(arg_3)
        else:
            create_single_command(arg_1[0])


def Func(arg_0, arg_1):
        """ get config for subparser and create commands"""
        arg_2 = arg_1.add_subparsers()
        for arg_3 in arg_0.config['subparsers']:
            arg_4 = arg_2.add_parser(arg_3)
            arg_0.create_commands(arg_0.config['subparsers'][arg_3], arg_4)


def Func(arg_0):
        """ custom command line  action to show version """
        class ShowVersionAction(argparse.Action):
            def __init__(arg_1, arg_2=0, **arg_3):
                super(ShowVersionAction, arg_1).__init__(arg_2=arg_2, **arg_3)

            def __call__(arg_1, arg_4, arg_5, arg_6, arg_7=None):
                print("{parser_name} version: {version}".format(
                    parser_name=arg_0.config.get(
                        "parser", {}).get("prog"),
                    version=arg_0.prog_version))
        return ShowVersionAction


def Func(arg_0, arg_1):
    """Return a launcher for a given clsname and kind.

    Parameters
    ==========
    clsname : str
        The full name of the launcher class, either with or without the
        module path, or an abbreviation (MPI, SSH, SGE, PBS, LSF,
        WindowsHPC).
    kind : str
        Either 'EngineSet' or 'Controller'.
    """
    if '.' not in arg_0:
        # not a module, presume it's the raw name in apps.launcher
        if arg_1 and arg_1 not in arg_0:
            # doesn't match necessary full class name, assume it's
            # just 'PBS' or 'MPI' prefix:
            arg_0 = arg_0 + arg_1 + 'Launcher'
        arg_0 = 'IPython.parallel.apps.launcher.'+arg_0
    arg_2 = import_item(arg_0)
    return arg_2


def Func(arg_0):
        """Start the app for the stop subcommand."""
        try:
            arg_1 = arg_0.get_pid_from_file()
        except PIDFileError:
            arg_0.log.critical(
                'Could not read pid file, cluster is probably not running.'
            )
            # Here I exit with a unusual exit status that other processes
            # can watch for to learn how I existed.
            arg_0.remove_pid_file()
            arg_0.exit(ALREADY_STOPPED)

        if not arg_0.check_pid(arg_1):
            arg_0.log.critical(
                'Cluster [pid=%r] is not running.' % arg_1
            )
            arg_0.remove_pid_file()
            # Here I exit with a unusual exit status that other processes
            # can watch for to learn how I existed.
            arg_0.exit(ALREADY_STOPPED)

        elif os.name=='posix':
            arg_2 = arg_0.signal
            arg_0.log.info(
                "Stopping cluster [pid=%r] with [signal=%r]" % (arg_1, arg_2)
            )
            try:
                os.kill(arg_1, arg_2)
            except OSError:
                arg_0.log.error("Stopping cluster failed, assuming already dead.",
                    exc_info=True)
                arg_0.remove_pid_file()
        elif os.name=='nt':
            try:
                # kill the whole tree
                arg_3 = check_call(['taskkill', '-pid', str(arg_1), '-t', '-f'], stdout=PIPE,stderr=PIPE)
            except (CalledProcessError, OSError):
                arg_0.log.error("Stopping cluster failed, assuming already dead.",
                    exc_info=True)
            arg_0.remove_pid_file()


def Func(arg_0, arg_1, arg_2=None):
        """import and instantiate a Launcher based on importstring"""
        try:
            arg_3 = find_launcher_class(arg_1, arg_2)
        except (ImportError, KeyError):
            arg_0.log.fatal("Could not import launcher class: %r"%arg_1)
            arg_0.exit(1)

        arg_4 = arg_3(
            work_dir=u'.', config=arg_0.config, log=arg_0.log,
            profile_dir=arg_0.profile_dir.location, cluster_id=arg_0.cluster_id,
        )
        return arg_4


def Func(arg_0):
        """Start the app for the engines subcommand."""
        arg_0.log.info("IPython cluster: Funced")
        # First see if the cluster is already running

        # Now log and daemonize
        arg_0.log.info(
            'Starting engines with [daemon=%r]' % arg_0.daemonize
        )
        # TODO: Get daemonize working on Windows or as a Windows Server.
        if arg_0.daemonize:
            if os.name=='posix':
                daemonize()

        arg_1 = ioloop.DelayedCallback(arg_0.Func_engines, 0, arg_0.loop)
        arg_1.Func()
        # Now write the new pid file AFTER our new forked pid is active.
        # self.write_pid_file()
        try:
            arg_0.loop.Func()
        except KeyboardInterrupt:
            pass
        except zmq.ZMQError as e:
            if e.errno == errno.EINTR:
                pass
            else:
                raise


def Func(arg_0):
        """Start the app for the Func subcommand."""
        # First see if the cluster is already running
        try:
            arg_1 = arg_0.get_pid_from_file()
        except PIDFileError:
            pass
        else:
            if arg_0.check_pid(arg_1):
                arg_0.log.critical(
                    'Cluster is already running with [pid=%s]. '
                    'use "ipcluster stop" to stop the cluster.' % arg_1
                )
                # Here I exit with a unusual exit status that other processes
                # can watch for to learn how I existed.
                arg_0.exit(ALREADY_STARTED)
            else:
                arg_0.remove_pid_file()

        # Now log and daemonize
        arg_0.log.info(
            'Starting ipcluster with [daemon=%r]' % arg_0.daemonize
        )
        # TODO: Get daemonize working on Windows or as a Windows Server.
        if arg_0.daemonize:
            if os.name=='posix':
                daemonize()

        arg_2 = ioloop.DelayedCallback(arg_0.Func_controller, 0, arg_0.loop)
        arg_2.Func()
        arg_2 = ioloop.DelayedCallback(arg_0.Func_engines, 1000*arg_0.delay, arg_0.loop)
        arg_2.Func()
        # Now write the new pid file AFTER our new forked pid is active.
        arg_0.write_pid_file()
        try:
            arg_0.loop.Func()
        except KeyboardInterrupt:
            pass
        except zmq.ZMQError as e:
            if e.errno == errno.EINTR:
                pass
            else:
                raise
        finally:
            arg_0.remove_pid_file()


def Func(arg_0):
    '''
    Return the consumer and oauth tokens with three-legged OAuth process and
    save in a yaml file in the user's home directory.
    '''

    print 'Retrieve API Key from https://www.shirts.io/accounts/api_console/'
    arg_1 = raw_input('Shirts.io API Key: ')

    arg_2 = {
        'api_key': arg_1,
    }

    arg_3 = open(arg_0, 'w+')
    yaml.dump(arg_2, arg_3, indent=2)
    arg_3.close()

    return arg_2


def Func(arg_0, arg_1):
  """Adds properties for all fields in this protocol message type."""
  arg_2 = arg_0.extensions_by_name
  for arg_3, arg_4 in arg_2.items():
    arg_5 = arg_3.upper() + "_FIELD_NUMBER"
    setattr(arg_1, arg_5, arg_4.number)


def Func(arg_0):
  """Unpacks Any message and returns the unpacked message.

  This internal method is differnt from public Any Unpack method which takes
  the target message as argument. Func method does not have
  target message type and need to find the message type in descriptor pool.

  Args:
    msg: An Any message to be unpacked.

  Returns:
    The unpacked message.
  """
  arg_1 = arg_0.type_url
  arg_2 = symbol_database.Default()

  if not arg_1:
    return None

  # TODO(haberman): For now we just strip the hostname.  Better logic will be
  # required.
  arg_3 = arg_1.split("/")[-1]
  arg_4 = arg_2.pool.FindMessageTypeByName(arg_3)

  if arg_4 is None:
    return None

  arg_5 = arg_2.GetPrototype(arg_4)
  arg_6 = arg_5()

  arg_6.ParseFromString(arg_0.value)
  return arg_6


def Func(*arg_0, **arg_1):
    """Create a new wx app or return an exiting one."""
    import wx
    arg_2 = wx.GetApp()
    if arg_2 is None:
        if not arg_1.has_key('redirect'):
            arg_1['redirect'] = False
        arg_2 = wx.PySimpleApp(*arg_0, **arg_1)
    return arg_2


def Func(arg_0=None):
    """Start the wx event loop in a consistent manner."""
    if arg_0 is None:
        arg_0 = get_app_wx()
    if not is_event_loop_running_wx(arg_0):
        arg_0._in_event_loop = True
        arg_0.MainLoop()
        arg_0._in_event_loop = False
    else:
        arg_0._in_event_loop = True


def Func(*arg_0, **arg_1):
    """Create a new qt4 app or return an existing one."""
    from IPython.external.qt_for_kernel import QtGui
    arg_2 = QtGui.QApplication.instance()
    if arg_2 is None:
        if not arg_0:
            arg_0 = ([''],)
        arg_2 = QtGui.QApplication(*arg_0, **arg_1)
    return arg_2


def Func(arg_0=None):
    """Is the qt4 event loop running."""
    if arg_0 is None:
        arg_0 = get_app_qt4([''])
    if hasattr(arg_0, '_in_event_loop'):
        return arg_0._in_event_loop
    else:
        # Does qt4 provide a other way to detect this?
        return False


def Func(arg_0=None):
    """Start the qt4 event loop in a consistent manner."""
    if arg_0 is None:
        arg_0 = get_app_qt4([''])
    if not is_event_loop_running_qt4(arg_0):
        arg_0._in_event_loop = True
        arg_0.exec_()
        arg_0._in_event_loop = False
    else:
        arg_0._in_event_loop = True


def Func(arg_0, arg_1):
        """Return a blank canvas to annotate.

        :param width: xdim (int)
        :param height: ydim (int)
        :returns: :class:`jicbioimage.illustrate.Canvas`
        """
        arg_2 = np.zeros((arg_1, arg_0, 3), dtype=np.uint8)
        return arg_2.view(Canvas)


def Func(arg_0, arg_1, arg_2=(255, 0, 0), arg_3=4):
        """Draw a cross on the canvas.

        :param position: (row, col) tuple
        :param color: RGB tuple
        :param radius: radius of the cross (int)
        """
        arg_4, arg_5 = arg_1
        for arg_6 in np.arange(-arg_3, arg_3+1, 1):
            arg_7 = arg_5 + arg_6
            if arg_7 < 0:
                continue  # Negative indices will draw on the opposite side.
            if arg_7 >= arg_0.shape[1]:
                continue  # Out of bounds.
            arg_0[arg_8(arg_4), arg_8(arg_7)] = arg_2
        for arg_9 in np.arange(-arg_3, arg_3+1, 1):
            arg_10 = arg_4 + arg_9
            if arg_10 < 0:
                continue  # Negative indices will draw on the opposite side.
            if arg_10 >= arg_0.shape[0]:
                continue  # Out of bounds.
            arg_0[arg_8(arg_10), arg_8(arg_5)] = arg_2


def Func(arg_0, arg_1=(True, True, True)):
        """Return a canvas from a grayscale image.

        :param im: single channel image
        :channels_on: channels to populate with input image
        :returns: :class:`jicbioimage.illustrate.Canvas`
        """
        arg_2, arg_3 = arg_0.shape
        arg_4 = np.zeros((arg_2, arg_3, 3), dtype=np.uint8)
        for arg_5, arg_6 in enumerate(arg_1):
            if arg_6:
                arg_4[:, :, arg_5] = arg_0
        return arg_4.view(AnnotatedImage)


def Func(arg_0=32, arg_1=1):
    """
    Returns a unique ID of a given length.
    User `version=2` for cross-systems uniqueness.
    """
    if arg_1 == 1:
        return uuid.uuid1().hex[:arg_0]
    else:
        return uuid.uuid4().hex[:arg_0]


def Func(arg_0):
    """ Returns a dictionary from a URL params """
    arg_1 = urllib.parse.urlparse(arg_0)
    arg_2 = urllib.parse.parse_qs(arg_1.query)
    return arg_2