parameters: (self, attrs=None, ad_value=None)
return_statement: return retdict
docstring: Utility method returning process information as a
          hashable dictionary.
          If *attrs* is specified it must be a list of strings
          reflecting available Process class' attribute names
          (e.g. ['cpu_times', 'name']) else all public (read
          only) attributes are assumed.
          *ad_value* is the value which gets assigned in case
          AccessDenied or ZombieProcess exception is raised when
          retrieving that particular process information.
docstring_summary: Utility method returning process information as a
          hashable dictionary.
          If *attrs* is specified it must be a list of strings
          reflecting available Process class' attribute names
          (e.g. ['cpu_times', 'name']) else all public (read
          only) attributes are assumed.
          *ad_value* is the value which gets assigned in case
          AccessDenied or ZombieProcess exception is raised when
          retrieving that particular process information.
docstring_tokens: Utility method returning process information as a hashable dictionary . If * attrs * is specified it must be a list of strings reflecting available Process class attribute names ( e . g . [ cpu_times name ] ) else all public ( read only ) attributes are assumed . * ad_value * is the value which gets assigned in case AccessDenied or ZombieProcess exception is raised when retrieving that particular process information .
function: def as_dict(self, attrs=None, ad_value=None):
          """Utility method returning process information as a
          hashable dictionary.
          If *attrs* is specified it must be a list of strings
          reflecting available Process class' attribute names
          (e.g. ['cpu_times', 'name']) else all public (read
          only) attributes are assumed.
          *ad_value* is the value which gets assigned in case
          AccessDenied or ZombieProcess exception is raised when
          retrieving that particular process information.
          """
          valid_names = _as_dict_attrnames
          if attrs is not None:
              if not isinstance(attrs, (list, tuple, set, frozenset)):
                  raise TypeError("invalid attrs type %s" % type(attrs))
              attrs = set(attrs)
              invalid_names = attrs - valid_names
              if invalid_names:
                  raise ValueError("invalid attr name%s %s" % (
                      "s" if len(invalid_names) > 1 else "",
                      ", ".join(map(repr, invalid_names))))
  
          retdict = dict()
          ls = attrs or valid_names
          with self.oneshot():
              for name in ls:
                  try:
                      if name == 'pid':
                          ret = self.pid
                      else:
                          meth = getattr(self, name)
                          ret = meth()
                  except (AccessDenied, ZombieProcess):
                      ret = ad_value
                  except NotImplementedError:
                      # in case of not implemented functionality (may happen
                      # on old or exotic systems) we want to crash only if
                      # the user explicitly asked for that particular attr
                      if attrs:
                          raise
                      continue
                  retdict[name] = ret
          return retdict
function_tokens: def as_dict ( self , attrs = None , ad_value = None ) : valid_names = _as_dict_attrnames if attrs is not None : if not isinstance ( attrs , ( list , tuple , set , frozenset ) ) : raise TypeError ( "invalid attrs type %s" % type ( attrs ) ) attrs = set ( attrs ) invalid_names = attrs - valid_names if invalid_names : raise ValueError ( "invalid attr name%s %s" % ( "s" if len ( invalid_names ) > 1 else "" , ", " . join ( map ( repr , invalid_names ) ) ) ) retdict = dict ( ) ls = attrs or valid_names with self . oneshot ( ) : for name in ls : try : if name == 'pid' : ret = self . pid else : meth = getattr ( self , name ) ret = meth ( ) except ( AccessDenied , ZombieProcess ) : ret = ad_value except NotImplementedError : # in case of not implemented functionality (may happen # on old or exotic systems) we want to crash only if # the user explicitly asked for that particular attr if attrs : raise continue retdict [ name ] = ret return retdict