def _calc_mem_info(self, unit, meminfo, memory):
if memory:<EOL><INDENT>total_mem_kib = meminfo["<STR_LIT>"]<EOL>used_mem_kib = (<EOL>total_mem_kib<EOL>- meminfo["<STR_LIT>"]<EOL>- (<EOL>meminfo["<STR_LIT>"]<EOL>+ meminfo["<STR_LIT>"]<EOL>+ (meminfo["<STR_LIT>"] - meminfo["<STR_LIT>"])<EOL>)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>total_mem_kib = meminfo["<STR_LIT>"]<EOL>used_mem_kib = total_mem_kib - meminfo["<STR_LIT>"]<EOL><DEDENT>used_percent = <NUM_LIT:100> * used_mem_kib / total_mem_kib<EOL>unit = "<STR_LIT:B>" if unit == "<STR_LIT>" else unit<EOL>(total, total_unit) = self.py3.format_units(total_mem_kib * <NUM_LIT>, unit)<EOL>(used, used_unit) = self.py3.format_units(used_mem_kib * <NUM_LIT>, unit)<EOL>return total, total_unit, used, used_unit, used_percent<EOL>
Parse /proc/meminfo, grab the memory capacity and used size
then return; Memory size 'total_mem', Used_mem, percentage
of used memory, and units of mem (KiB, MiB, GiB).