<s> from jinja2 import Undefined <EOL> from lektor . environment import PRIMARY_ALT <EOL> class BadValue ( Undefined ) : <EOL> __slots__ = ( ) <EOL> def get_undefined_info ( undefined ) : <EOL> if isinstance ( undefined , Undefined ) : <EOL> try : <EOL> undefined . _fail_with_undefined_error ( ) <EOL> except Exception as e : <EOL> return e . message <EOL> return '<STR_LIT>' <EOL> class RawValue ( object ) : <EOL> __slots__ = ( '<STR_LIT:name>' , '<STR_LIT:value>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self , name , value = None , field = None , pad = None ) : <EOL> self . name = name <EOL> self . value = value <EOL> self . field = field <EOL> self . pad = pad <EOL> def _get_hint ( self , prefix , reason ) : <EOL> if self . field is not None : <EOL> return '<STR_LIT>' % ( prefix , self . field . name , reason ) <EOL> return '<STR_LIT>' % ( prefix , reason ) <EOL> def bad_value ( self , reason , value = None ) : <EOL> return BadValue ( hint = self . _get_hint ( '<STR_LIT>' , reason ) , <EOL> obj = self . value ) <EOL> def missing_value ( self , reason ) : <EOL> return Undefined ( hint = self . _get_hint ( '<STR_LIT>' , reason ) , <EOL> obj = self . value ) <EOL> class Type ( object ) : <EOL> def __init__ ( self , env , options ) : <EOL> self . env = env <EOL> self . options = options <EOL> @ property <EOL> def size ( self ) : <EOL> size = self . options . get ( '<STR_LIT:size>' ) or '<STR_LIT>' <EOL> if size not in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> size = '<STR_LIT>' <EOL> return size <EOL> @ property <EOL> def width ( self ) : <EOL> return self . options . get ( '<STR_LIT:width>' ) or '<STR_LIT>' <EOL> @ property <EOL> def name ( self ) : <EOL> rv = self . __class__ . __name__ <EOL> if rv . endswith ( '<STR_LIT>' ) : <EOL> rv = rv [ : - <NUM_LIT:4> ] <EOL> return rv . lower ( ) <EOL> def to_json ( self , pad , record = None , alt = PRIMARY_ALT ) : <EOL> return { <EOL> '<STR_LIT:name>' : self . name , <EOL> '<STR_LIT:size>' : self . size , <EOL> '<STR_LIT:width>' : self . width , <EOL> } <EOL> def value_from_raw ( self , raw ) : <EOL> return raw <EOL> def value_from_raw_with_default ( self , raw ) : <EOL> value = self . value_from_raw ( raw ) <EOL> if isinstance ( value , Undefined ) and raw . field is not None and raw . field . default is not None : <EOL> return self . value_from_raw ( RawValue ( raw . name , raw . field . default , <EOL> field = raw . field , pad = raw . pad ) ) <EOL> return value <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . __class__ . __name__ <EOL> from lektor . types . primitives import StringType , StringsType , TextType , HtmlType , IntegerType , FloatType , BooleanType , DateType <EOL> from lektor . types . multi import CheckboxesType , SelectType <EOL> from lektor . types . special import SortKeyType , SlugType , UrlType <EOL> from lektor . types . formats import MarkdownType <EOL> from lektor . types . flow import FlowType <EOL> from lektor . types . fake import LineType , SpacingType , InfoType , HeadingType <EOL> builtin_types = { <EOL> '<STR_LIT:string>' : StringType , <EOL> '<STR_LIT>' : StringsType , <EOL> '<STR_LIT:text>' : TextType , <EOL> '<STR_LIT:html>' : HtmlType , <EOL> '<STR_LIT>' : IntegerType , <EOL> '<STR_LIT:float>' : FloatType , <EOL> '<STR_LIT>' : BooleanType , <EOL> '<STR_LIT:date>' : DateType , <EOL> '<STR_LIT>' : CheckboxesType , <EOL> '<STR_LIT>' : SelectType , <EOL> '<STR_LIT>' : SortKeyType , <EOL> '<STR_LIT>' : SlugType , <EOL> '<STR_LIT:url>' : UrlType , <EOL> '<STR_LIT>' : MarkdownType , <EOL> '<STR_LIT>' : FlowType , <EOL> '<STR_LIT>' : LineType , <EOL> '<STR_LIT>' : SpacingType , <EOL> '<STR_LIT:info>' : InfoType , <EOL> '<STR_LIT>' : HeadingType , <EOL> } </s>
