#NEWLINE# def contains( filename , text , exact = False , use_sudo = False , escape = True , shell = False , case_sensitive = True ) : #NEWLINE# #INDENT# "\n    Return True if ``filename`` contains ``text`` (which may be a regex.)\n\n    By default, this function will consider a partial line match (i.e. where\n    ``text`` only makes up part of the line it's on). Specify ``exact=True`` to\n    change this behavior so that only a line containing exactly ``text``\n    results in a True return value.\n\n    This function leverages ``egrep`` on the remote end (so it may not follow\n    Python regular expression syntax perfectly), and skips ``env.shell``\n    wrapper by default.\n\n    If ``use_sudo`` is True, will use `sudo` instead of `run`.\n\n    If ``escape`` is False, no extra regular expression related escaping is\n    performed (this includes overriding ``exact`` so that no ``^``/``$`` is\n    added.)\n\n    The ``shell`` argument will be eventually passed to ``run/sudo``. See\n    description of the same argumnet in ``~fabric.contrib.sed`` for details.\n\n    If ``case_sensitive`` is False, the `-i` flag will be passed to ``egrep``.\n\n    .. versionchanged:: 1.0\n        Swapped the order of the ``filename`` and ``text`` arguments to be\n        consistent with other functions in this module.\n    .. versionchanged:: 1.4\n        Updated the regular expression related escaping to try and solve\n        various corner cases.\n    .. versionchanged:: 1.4\n        Added ``escape`` keyword argument.\n    .. versionadded:: 1.6\n        Added the ``shell`` keyword argument.\n    .. versionadded:: 1.11\n        Added the ``case_sensitive`` keyword argument.\n    " #NEWLINE# func = ( ( use_sudo and sudo ) or run ) #NEWLINE# if escape : #NEWLINE# #INDENT# text = _escape_for_regex ( exact ) #NEWLINE# if exact : #NEWLINE# #INDENT# text = ( '^%s$' % text ) #NEWLINE# #UNINDENT# #UNINDENT# with settings ( hide ( 'everything' ) , warn_only = True ) : #NEWLINE# #INDENT# egrep_cmd = ( 'egrep "%s" %s' % ( text , _expand_path ( filename ) ) ) #NEWLINE# if ( not case_sensitive ) : #NEWLINE# #INDENT# egrep_cmd = egrep_cmd . replace ( 'egrep' , 'egrep -i' , 1 ) #NEWLINE# #UNINDENT# return func ( egrep_cmd , shell = shell ) . succeeded