def check_symlinks(directory, symlinks=True):
 for (root, _, files) in os.walk(directory):
  for f in files:
   p = os.path.join(root, f)
   if (symlinks ^ os.path.islink(p)):
    return False
 return True

def check_symlinks ( directory , symlinks = True ) : for ( root , _ , files ) in os . walk ( directory ) : for f in files : p = os . path . join ( root , f ) if ( symlinks ^ os . path . islink ( p ) ) : return False return True
check files under directory are symlinks .