<s> """<STR_LIT>""" <EOL> import psutil <EOL> def bytes2human ( n ) : <EOL> symbols = ( '<STR_LIT>' , '<STR_LIT:M>' , '<STR_LIT>' , '<STR_LIT:T>' , '<STR_LIT:P>' , '<STR_LIT:E>' , '<STR_LIT>' , '<STR_LIT:Y>' ) <EOL> prefix = { } <EOL> for i , s in enumerate ( symbols ) : <EOL> prefix [ s ] = <NUM_LIT:1> << ( i + <NUM_LIT:1> ) * <NUM_LIT:10> <EOL> for s in reversed ( symbols ) : <EOL> if n >= prefix [ s ] : <EOL> value = float ( n ) / prefix [ s ] <EOL> return '<STR_LIT>' % ( value , s ) <EOL> return "<STR_LIT>" % n <EOL> def pprint_ntuple ( nt ) : <EOL> for name in nt . _fields : <EOL> value = getattr ( nt , name ) <EOL> if name != '<STR_LIT>' : <EOL> value = bytes2human ( value ) <EOL> print ( '<STR_LIT>' % ( name . capitalize ( ) , value ) ) <EOL> def main ( ) : <EOL> print ( '<STR_LIT>' ) <EOL> pprint_ntuple ( psutil . virtual_memory ( ) ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint_ntuple ( psutil . swap_memory ( ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
