def folder_size(pth, ignore=None):
 if (not os.path.isdir(pth)):
  raise exc.FolderNotFound
 ignore = coerce_to_list(ignore)
 def get_size(total, root, names):
  paths = [os.path.realpath(os.path.join(root, nm)) for nm in names]
  for pth in paths[::(-1)]:
   if (not os.path.exists(pth)):
    paths.remove(pth)
   elif os.path.isdir(pth):
    paths.remove(pth)
   elif match_pattern(pth, ignore):
    paths.remove(pth)
  total[0] += sum((os.stat(pth).st_size for pth in paths))
 total = [0]
 os.path.walk(pth, get_size, total)
 return total[0]

def folder_size ( pth , ignore = None ) : if ( not os . path . isdir ( pth ) ) : raise exc . FolderNotFound ignore = coerce_to_list ( ignore ) def get_size ( total , root , names ) : paths = [ os . path . realpath ( os . path . join ( root , nm ) ) for nm in names ] for pth in paths [ : : ( - 1 ) ] : if ( not os . path . exists ( pth ) ) : paths . remove ( pth ) elif os . path . isdir ( pth ) : paths . remove ( pth ) elif match_pattern ( pth , ignore ) : paths . remove ( pth ) total [ 0 ] += sum ( ( os . stat ( pth ) . st_size for pth in paths ) ) total = [ 0 ] os . path . walk ( pth , get_size , total ) return total [ 0 ]
returns the total bytes for the specified path .