Strip Juniper-specific output.

        Juniper will also put a configuration context:
        [edit]

        and various chassis contexts:
        {master:0}, {backup:1}

        This method removes those lines.
9236
def strip_context_items(self, a_string):
        
        strings_to_strip = [
            r"\[edit.*\]",
            r"\{master:.*\}",
            r"\{backup:.*\}",
            r"\{line.*\}",
            r"\{primary.*\}",
            r"\{secondary.*\}",
        ]

        response_list = a_string.split(self.RESPONSE_RETURN)
        last_line = response_list[-1]

        for pattern in strings_to_strip:
            if re.search(pattern, last_line):
                return self.RESPONSE_RETURN.join(response_list[:-1])
        return a_string
535491
def do_removerep(self, line):
        """"""
        mns = self._split_args(line, 1, -1)
        self._command_processor.get_session().get_replication_policy().repremove(mns)
        self._print_info_if_verbose(
            "Removed {} from replication policy".format(", ".join(mns))
        )
226779
def cleanup(self):
        '''
        
        '''

        hostname = get_hostname()
        old_branch = self.branch

        changes = self.status
        if not changes.get('clean'):

            self.branch = hostname
            utmo = changes.get('untracked', []) + changes.get('modified', [])

            for f in utmo:
                self.m(
                    'adding file to repository',
                    cmdd=(dict(cmd='git add %s' % (f), cwd=self.local)),
                    more=f,
                    critical=False
                )
            for f in changes.get('deleted', []):
                self.m(
                    'deleting file from repository',
                    cmdd=(dict(cmd='git rm %s' % (f), cwd=self.local)),
                    more=f,
                    critical=False
                )
            if changes.get('conflicting'):
                self.m(
                    'Well done! You have conflicting files in the repository!',
                    state=True,
                    more=changes
                )

            self.m(
                'auto commiting changes',
                cmdd=dict(
                    cmd='git commit -m "%s %s auto commit"' % (
                        hostname, IDENT
                    ),
                    cwd=self.local
                ),
                more=changes
            )

            self.branch = None

            self.m(
                'auto merging branches',
                cmdd=dict(
                    cmd='git merge %s -m "%s %s auto merge"' % (
                        hostname, hostname, IDENT
                    ),
                    cwd=self.local
                ),
                more=dict(
                    branch=old_branch,
                    temp_branch=hostname
                )
            )

            self.branch = old_branch
        return dict(changes=changes, pull=self._pull())
1311996
function removeNode(context, node) {
  var removedNodes = context.removedNodes;
  var length = removedNodes.length;
  var index = length;

  // Check for line's leading and trailing space to be removed.
  var spaceNode = context.pretty ? getLeadingSpaceNode(context, node) : null;
  var lineNode = context.pretty ? getTrailingLineNode(context, node) : null;

  while (index > 0 && removedNodes[index - 1].end > node.start) {
    index--;
  }

  if (index === length) {
    if (spaceNode) {
      removedNodes.push(spaceNode);
    }
    removedNodes.push(node);
    if (lineNode) {
      removedNodes.push(lineNode);
    }
  } else {
    if (lineNode) {
      if (spaceNode) {
        removedNodes.splice(index, 0, spaceNode, node, lineNode);
      } else {
        removedNodes.splice(index, 0, node, lineNode);
      }
    } else if (spaceNode) {
      removedNodes.splice(index, 0, spaceNode, node);
    } else {
      removedNodes.splice(index, 0, node);
    }
  }

  return false;
}
280804
def _format_master(service,
                   conn_type,
                   private,
                   unpriv,
                   chroot,
                   wakeup,
                   maxproc,
                   command):
    '''
    
    '''
    #==========================================================================
    #service type  private unpriv  chroot  wakeup  maxproc command + args
    #              (yes)   (yes)   (yes)   (never) (100)
    #==========================================================================
    #smtp      inet  n       -       n       -       -       smtpd
    if private == 'y':
        private = '-'

    if unpriv == 'y':
        unpriv = '-'

    if chroot == 'y':
        chroot = '-'

    if wakeup == 'n':
        wakeup = '-'

    maxproc = six.text_type(maxproc)
    if maxproc == '100':
        maxproc = '-'

    conf_line = '{0:9s} {1:5s} {2:7s} {3:7s} {4:7s} {5:7s} {6:7s} {7}'.format(
        service,
        conn_type,
        private,
        unpriv,
        chroot,
        wakeup,
        maxproc,
        command,
    )
    #print(conf_line)
    return conf_line
562312
def cleanup_config_line(line)
        #remove comments, even those that happen inline
        line.gsub!(/^((".*?"|[^#"])*)#.*/) {|m| m=$1}

        #fix whitespace
        line.gsub!('=', ' = ')
        line.gsub!(/\s+/, ' ')
        line.strip
      end
151913
def cleanup(config=None, path=None):
    """"""
    if config is None:
        config = parse()
    if path is None:
        path = os.getcwd()
    root = config.get('root', 'path')
    root = os.path.join(path, root)
    if sys.path[0] == root:
        sys.path.remove(root)
286415
function (rawLine) {
    // Maven on the Travis-CI Ubunty Trusty container makes the version line bold.
    // Let's just say I'm pretty salty at this point. So we strip ANSI codes.
    var line = stripAnsi(rawLine);
    debug('Checking cmd output: ' + line);
    var match = line.match(re);
    if (match !== null) {
      retv = match;
    }
  }
854485
def strip_wsgi(request):
    """"""

    meta = copy(request.META)
    for key in meta:
        if key[:4] == 'wsgi':
            meta[key] = None
    return meta
611412
def _remove_empty_output(self):
        
        output = []
        for key in self.output_dict:
            if self.output_dict[key] is not None and 'full_text' in self.output_dict[key]:
                output.append(self.output_dict[key])
        return output
1237815
def _remove_bdb_context(evalue):
        
        removed_bdb_context = evalue
        while removed_bdb_context.__context__:
            ctx = removed_bdb_context.__context__
            if (
                isinstance(ctx, AttributeError)
                and ctx.__traceback__.tb_frame.f_code.co_name == "onecmd"
            ):
                removed_bdb_context.__context__ = None
                break
            removed_bdb_context = removed_bdb_context.__context__
937370
def _clean_java_out(version_str):
    
    out = []
    for line in version_str.decode().split("\n"):
        if line.startswith("Picked up"):
            pass
        if line.find("setlocale") > 0:
            pass
        else:
            out.append(line)
    return "\n".join(out)
1250342
def cleanup(self):
        """"""
        if self.allow_disable_global:
            # Return paging state
            output_mode_cmd = "set output {}".format(self._output_mode)
            enable_paging_commands = ["config system console", output_mode_cmd, "end"]
            if self.vdoms:
                enable_paging_commands.insert(0, "config global")
            # Should test output is valid
            for command in enable_paging_commands:
                self.send_command_timing(command)
506380
def strip(parser, arg):
    
    nodelist = parser.parse(('endstrip',))
    parser.delete_first_token()
    return StripNode(nodelist, arg.split_contents())
1277994
def cleanLines(source, lineSep=os.linesep):
    
    stripped = (line.strip(lineSep) for line in source)
    return (line for line in stripped if len(line) != 0)
126170
def remove_indent_lines(s):
    
    if not s:
        return ""
    lines = s.splitlines(True)
    prefix = get_same_indent_prefix(lines)
    if prefix is None:  # not in expected format. just lstrip all lines
        return "".join([l.lstrip() for l in lines])
    return "".join([l[len(prefix):] for l in lines])
360453
def unset(self, host, *args):
        
        self.__check_host_args(host, args)
        remove_idx = [idx for idx, x in enumerate(self.lines_)
                      if x.host == host and x.key.lower() in args]
        for idx in reversed(sorted(remove_idx)):
            del self.lines_[idx]