def simple_format(s, keys, pattern=RE_FORMAT, expand=u'\\1'):
 if s:
  keys.setdefault(u'%', u'%')
  def resolve(match):
   key = match.expand(expand)
   try:
    resolver = keys[key]
   except KeyError:
    raise ValueError(UNKNOWN_SIMPLE_FORMAT_KEY.format(key, s))
   if isinstance(resolver, Callable):
    return resolver()
   return resolver
  return pattern.sub(resolve, s)
 return s

def simple_format ( s , keys , pattern = RE_FORMAT , expand = u'\\1' ) : if s : keys . setdefault ( u'%' , u'%' ) def resolve ( match ) : key = match . expand ( expand ) try : resolver = keys [ key ] except KeyError : raise ValueError ( UNKNOWN_SIMPLE_FORMAT_KEY . format ( key , s ) ) if isinstance ( resolver , Callable ) : return resolver ( ) return resolver return pattern . sub ( resolve , s ) return s
format string .