Revision 403f5172

b/lib/bdev.py
389 389
    pvs_info.reverse()
390 390

  
391 391
    pvlist = [ pv[1] for pv in pvs_info ]
392
    if compat.any(pvlist, lambda v: ":" in v):
392
    if compat.any(":" in v for v in pvlist):
393 393
      _ThrowError("Some of your PVs have the invalid character ':' in their"
394 394
                  " name, this is not supported - please filter them out"
395 395
                  " in lvm.conf using either 'filter' or 'preferred_names'")
......
463 463
    """
464 464
    if (not cls._VALID_NAME_RE.match(name) or
465 465
        name in cls._INVALID_NAMES or
466
        compat.any(cls._INVALID_SUBSTRINGS, lambda x: x in name)):
466
        compat.any(substring in name for substring in cls._INVALID_SUBSTRINGS)):
467 467
      _ThrowError("Invalid LVM name '%s'", name)
468 468

  
469 469
  def Remove(self):
b/lib/cmdlib.py
176 176

  
177 177
  """
178 178
  return _TAnd(_TList,
179
               lambda lst: compat.all(lst, my_type))
179
               lambda lst: compat.all(my_type(v) for v in lst))
180 180

  
181 181

  
182 182
def _TDictOf(key_type, val_type):
......
184 184

  
185 185
  """
186 186
  return _TAnd(_TDict,
187
               lambda my_dict: (compat.all(my_dict.keys(), key_type) and
188
                                compat.all(my_dict.values(), val_type)))
187
               lambda my_dict: (compat.all(key_type(v) for v in my_dict.keys())
188
                                and compat.all(val_type(v)
189
                                               for v in my_dict.values())))
189 190

  
190 191

  
191 192
# End types
......
1744 1745

  
1745 1746
    remote_os = nresult.get(constants.NV_OSLIST, None)
1746 1747
    test = (not isinstance(remote_os, list) or
1747
            not compat.all(remote_os,
1748
                           lambda v: isinstance(v, list) and len(v) == 7))
1748
            not compat.all(isinstance(v, list) and len(v) == 7
1749
                           for v in remote_os))
1749 1750

  
1750 1751
    _ErrorIf(test, self.ENODEOS, node,
1751 1752
             "node hasn't returned valid OS data")
......
1794 1795
               "OS '%s' has multiple entries (first one shadows the rest): %s",
1795 1796
               os_name, utils.CommaJoin([v[0] for v in os_data]))
1796 1797
      # this will catched in backend too
1797
      _ErrorIf(compat.any(f_api, lambda v: v >= constants.OS_API_V15)
1798
      _ErrorIf(compat.any(v >= constants.OS_API_V15 for v in f_api)
1798 1799
               and not f_var, self.ENODEOS, node,
1799 1800
               "OS %s with API at least %d does not declare any variant",
1800 1801
               os_name, constants.OS_API_V15)
b/lib/compat.py
55 55
  sha1_hash = sha.new
56 56

  
57 57

  
58
def all(seq, pred=bool): # pylint: disable-msg=W0622
59
  """Returns True if pred(x) is True for every element in the iterable.
60

  
61
  Please note that this function provides a C{pred} parameter which isn't
62
  available in the version included in Python 2.5 and above.
58
def _all(seq):
59
  """Returns True if all elements in the iterable are True.
63 60

  
64 61
  """
65
  for _ in itertools.ifilterfalse(pred, seq):
62
  for _ in itertools.ifilterfalse(bool, seq):
66 63
    return False
67 64
  return True
68 65

  
69

  
70
def any(seq, pred=bool): # pylint: disable-msg=W0622
71
  """Returns True if pred(x) is True for at least one element in the iterable.
72

  
73
  Please note that this function provides a C{pred} parameter which isn't
74
  available in the version included in Python 2.5 and above.
66
def _any(seq):
67
  """Returns True if any element of the iterable are True.
75 68

  
76 69
  """
77
  for _ in itertools.ifilter(pred, seq):
70
  for _ in itertools.ifilter(bool, seq):
78 71
    return True
79 72
  return False
80 73

  
74
try:
75
  all = all # pylint: disable-msg=W0622
76
except NameError:
77
  all = _all
78

  
79
try:
80
  any = any # pylint: disable-msg=W0622
81
except NameError:
82
  any = _any
81 83

  
82 84
def partition(seq, pred=bool): # pylint: disable-msg=W0622
83 85
  """Partition a list in two, based on the given predicate.
......
106 108
  return newfunc
107 109

  
108 110

  
111
if functools is None:
112
  partial = _partial
113
else:
114
  partial = functools.partial
115

  
116

  
109 117
def TryToRoman(val, convert=True):
110 118
  """Try to convert a value to roman numerals
111 119

  
......
128 136
  else:
129 137
    return val
130 138

  
131

  
132
if functools is None:
133
  partial = _partial
134
else:
135
  partial = functools.partial
b/lib/masterd/instance.py
793 793
          logging.exception("%s failed", diskie.MODE_TEXT)
794 794
          diskie.Finalize(error=str(err))
795 795

  
796
      if not compat.any([diskie.active for diskie in self._queue]):
796
      if not compat.any(diskie.active for diskie in self._queue):
797 797
        break
798 798

  
799 799
      # Wait a bit
......
1060 1060
    ieloop.FinalizeAll()
1061 1061

  
1062 1062
  assert len(all_dtp) == len(all_transfers)
1063
  assert compat.all([(dtp.src_export is None or
1063
  assert compat.all((dtp.src_export is None or
1064 1064
                      dtp.src_export.success is not None) and
1065 1065
                     (dtp.dest_import is None or
1066 1066
                      dtp.dest_import.success is not None)
1067
                     for dtp in all_dtp]), \
1067
                     for dtp in all_dtp), \
1068 1068
         "Not all imports/exports are finalized"
1069 1069

  
1070 1070
  return [bool(dtp.success) for dtp in all_dtp]
b/scripts/gnt-cluster
433 433

  
434 434
  if missing:
435 435
    for iname, ival in missing.iteritems():
436
      all_missing = compat.all(ival, lambda x: x[0] in bad_nodes)
436
      all_missing = compat.all(x[0] in bad_nodes for x in ival)
437 437
      if all_missing:
438 438
        ToStdout("Instance %s cannot be verified as it lives on"
439 439
                 " broken nodes", iname)
b/tools/burnin
987 987
        self.BurnReplaceDisks2()
988 988

  
989 989
      if (opts.disk_template in constants.DTS_GROWABLE and
990
          compat.any(self.disk_growth, lambda n: n > 0)):
990
          compat.any(n > 0 for n in self.disk_growth)):
991 991
        self.BurnGrowDisks()
992 992

  
993 993
      if opts.do_failover and opts.disk_template in constants.DTS_NET_MIRROR:

Also available in: Unified diff