Revision 16091a6e lib/ht.py

b/lib/ht.py
364 364
TRelativeJobId = WithDesc("RelativeJobId")(TNegativeInt)
365 365

  
366 366

  
367
def TInstanceOf(my_inst):
368
  """Checks if a given value is an instance of my_inst.
367
def TInstanceOf(cls):
368
  """Checks if a given value is an instance of C{cls}.
369

  
370
  @type cls: class
371
  @param cls: Class object
369 372

  
370 373
  """
371
  desc = WithDesc("Instance of %s" % (Parens(my_inst), ))
372
  return desc(lambda val: isinstance(val, my_inst))
374
  name = "%s.%s" % (cls.__module__, cls.__name__)
375

  
376
  desc = WithDesc("Instance of %s" % (Parens(name), ))
377

  
378
  return desc(lambda val: isinstance(val, cls))
373 379

  
374 380

  
375 381
def TListOf(my_type):

Also available in: Unified diff