code: def battery_percent(self):
          
          if not batinfo_tag or not self.bat.stat:
              return []
  
          # Init the bsum (sum of percent)
          # and Loop over batteries (yes a computer could have more than 1 battery)
          bsum = 0
          for b in self.bat.stat:
              try:
                  bsum += int(b.capacity)
              except ValueError:
                  return []
  
          # Return the global percent
          return int(bsum / len(self.bat.stat))
docs: Get batteries capacity percent.