def Parse(self, cmd, args, stdout, stderr, return_val, time_taken,
            knowledge_base):
    """Parse the ps output.

    Note that cmdline consumes every field up to the end of line
    and as it is string, we can't perfectly see what the arguments
    on the command line really were. We just assume a space is the arg
    seperator. It's imperfect, but it's better than nothing.
    Obviously, if cmd/cmdline is specified, it must be the last
    column of output.

    Args:
      cmd: A string containing the base command that was run.
      args: A list of strings containing the commandline args for the command.
      stdout: A string containing the stdout of the command run.
      stderr: A string containing the stderr of the command run. (Unused)
      return_val: The return code following command execution.
      time_taken: The time taken to run the process. (Unused)
      knowledge_base: An RDF KnowledgeBase. (Unused)

    Yields:
      RDF Process objects.
    """

    _ = stderr, time_taken, knowledge_base  # Unused.
    self.CheckReturn(cmd, return_val)

    if not stdout:
      # We have nothing to process so bug out. (Handles a input of None.)
      return

    rdf_convert_table = {"pid": ("pid", int),
                         "tgid": ("pid", int),
                         "ppid": ("ppid", int),
                         "comm": ("name", str),
                         "ucomm": ("name", str),
                         "ruid": ("real_uid", int),
                         "uid": ("effective_uid", int),
                         "euid": ("effective_uid", int),
                         "suid": ("saved_uid", int),
                         "svuid": ("saved_uid", int),
                         "user": ("username", str),
                         "euser": ("username", str),
                         "uname": ("username", str),
                         "rgid": ("real_gid", int),
                         "gid": ("effective_gid", int),
                         "egid": ("effective_gid", int),
                         "sgid": ("saved_gid", int),
                         "svgid": ("saved_gid", int),
                         "tty": ("terminal", str),
                         "tt": ("terminal", str),
                         "tname": ("terminal", str),
                         "stat": ("status", str),
                         "nice": ("nice", int),
                         "ni": ("nice", int),
                         "thcount": ("num_threads", int),
                         "nlwp": ("num_threads", int),
                         "pcpu": ("cpu_percent", float),
                         "%cpu": ("cpu_percent", float),
                         "c": ("cpu_percent", float),
                         "rss": ("RSS_size", long),
                         "rssize": ("RSS_size", long),
                         "rsz": ("RSS_size", long),
                         "vsz": ("VMS_size", long),
                         "vsize": ("VMS_size", long),
                         "pmem": ("memory_percent", float),
                         "%mem": ("memory_percent", float),
                         "args": ("cmdline", self._SplitCmd),
                         "command": ("cmdline", self._SplitCmd),
                         "cmd": ("cmdline", self._SplitCmd)}

    expected_fields = self._FindPsOutputFormat(cmd, args)

    # If we made it here, we expect we can now parse the output and we know
    # expected its format.

    lines = stdout.splitlines()
    if self._HasHeaders(args):
      # Ignore the headers.
      lines = lines[1:]

    for line in lines:
      try:
        # The "len() - 1" allows us to group any extra fields into
        # the last field. e.g. cmdline.
        entries = line.split(None, 1 - len(expected_fields))
        # Create an empty process for us to fill in as best we can.
        process = rdf_client.Process()
        for name, value in zip(expected_fields, entries):
          if name not in rdf_convert_table:
            # If the field is not something we can process, skip it.
            continue
          rdf_name, method = rdf_convert_table[name]
          setattr(process, rdf_name, method(value))
        # Approximate the 'comm' from the cmdline if it wasn't detailed.
        # i.e. the basename of the first arg of the commandline.
        if not process.name and process.cmdline:
          process.name = os.path.basename(process.cmdline[0])
        yield process
      except ValueError:
        logging.warn("Unparsable line found for %s %s:\n"
                     "  %s", cmd, args, line)
dataset/ETHPy150Open google/grr/grr/parsers/linux_cmd_parser.py/PsCmdParser.Parse/swapped operands of `-`