def FromFile(f, more_formatters=(lambda x: None), _constructor=None):
 _constructor = (_constructor or Template)
 options = {}
 while 1:
  line = f.readline()
  match = _OPTION_RE.match(line)
  if match:
   (name, value) = (match.group(1), match.group(2))
   name = name.lower()
   if (name in _OPTION_NAMES):
    name = name.replace('-', '_')
    value = value.strip()
    if ((name == 'default_formatter') and (value.lower() == 'none')):
     value = None
    options[name] = value
   else:
    break
  else:
   break
 if options:
  if line.strip():
   raise CompilationError(('Must be one blank line between template options and body (got %r)' % line))
  body = f.read()
 else:
  body = (line + f.read())
 return _constructor(body, more_formatters=more_formatters, **options)

def FromFile ( f , more_formatters = ( lambda x : None ) , _constructor = None ) : _constructor = ( _constructor or Template ) options = { } while 1 : line = f . readline ( ) match = _OPTION_RE . match ( line ) if match : ( name , value ) = ( match . group ( 1 ) , match . group ( 2 ) ) name = name . lower ( ) if ( name in _OPTION_NAMES ) : name = name . replace ( '-' , '_' ) value = value . strip ( ) if ( ( name == 'default_formatter' ) and ( value . lower ( ) == 'none' ) ) : value = None options [ name ] = value else : break else : break if options : if line . strip ( ) : raise CompilationError ( ( 'Must be one blank line between template options and body (got %r)' % line ) ) body = f . read ( ) else : body = ( line + f . read ( ) ) return _constructor ( body , more_formatters = more_formatters , ** options )
parse a template from a file .