def disk_used(path):
 size = 0
 for file in (os.listdir(path) + ['.']):
  stat = os.stat(os.path.join(path, file))
  if hasattr(stat, 'st_blocks'):
   size += (stat.st_blocks * 512)
  else:
   size += (((stat.st_size // 512) + 1) * 512)
 return int((size / 1024.0))

def disk_used ( path ) : size = 0 for file in ( os . listdir ( path ) + [ '.' ] ) : stat = os . stat ( os . path . join ( path , file ) ) if hasattr ( stat , 'st_blocks' ) : size += ( stat . st_blocks * 512 ) else : size += ( ( ( stat . st_size // 512 ) + 1 ) * 512 ) return int ( ( size / 1024.0 ) )
return the disk usage in a directory .