code: def rapl_read():
      
      basenames = glob.glob('/sys/class/powercap/intel-rapl:*/')
      basenames = sorted(set({x for x in basenames}))
  
      pjoin = os.path.join
      ret = list()
      for path in basenames:
          name = None
          try:
              name = cat(pjoin(path, 'name'), fallback=None, binary=False)
          except (IOError, OSError, ValueError) as err:
              logging.warning("ignoring %r for file %r",
                              (err, path), RuntimeWarning)
              continue
          if name:
              try:
                  current = cat(pjoin(path, 'energy_uj'))
                  max_reading = 0.0
                  ret.append(RaplStats(name, float(current), max_reading))
              except (IOError, OSError, ValueError) as err:
                  logging.warning("ignoring %r for file %r",
                                  (err, path), RuntimeWarning)
      return ret
docs: Read power stats and return dictionary