def as_template(value):
 if isinstance(value, Template):
  return value
 elif isinstance(value, collections.Mapping):
  return MappingTemplate(value)
 elif (value is int):
  return Integer()
 elif isinstance(value, int):
  return Integer(value)
 elif (isinstance(value, type) and issubclass(value, BASESTRING)):
  return String()
 elif isinstance(value, BASESTRING):
  return String(value)
 elif isinstance(value, set):
  return Choice(list(value))
 elif isinstance(value, list):
  return OneOf(value)
 elif (value is float):
  return Number()
 elif (value is None):
  return Template()
 elif (value is dict):
  return TypeTemplate(collections.Mapping)
 elif (value is list):
  return TypeTemplate(collections.Sequence)
 elif isinstance(value, type):
  return TypeTemplate(value)
 else:
  raise ValueError(u'cannot convert to template: {0!r}'.format(value))

def as_template ( value ) : if isinstance ( value , Template ) : return value elif isinstance ( value , collections . Mapping ) : return MappingTemplate ( value ) elif ( value is int ) : return Integer ( ) elif isinstance ( value , int ) : return Integer ( value ) elif ( isinstance ( value , type ) and issubclass ( value , BASESTRING ) ) : return String ( ) elif isinstance ( value , BASESTRING ) : return String ( value ) elif isinstance ( value , set ) : return Choice ( list ( value ) ) elif isinstance ( value , list ) : return OneOf ( value ) elif ( value is float ) : return Number ( ) elif ( value is None ) : return Template ( ) elif ( value is dict ) : return TypeTemplate ( collections . Mapping ) elif ( value is list ) : return TypeTemplate ( collections . Sequence ) elif isinstance ( value , type ) : return TypeTemplate ( value ) else : raise ValueError ( u'cannot convert to template: {0!r}' . format ( value ) )
convert a simple "shorthand" python value to a template .