src/prost/prost.py
def recursive_format(obj: TemplateObj, mapping: Dict,
                     ignore_missing: bool = False) -> TemplateObj:
  """Formats all strings within an object, using mapping
    
  Args:
    obj: Object (leaves must be strings, regardless of type)
    mapping: format dictionary, maps keys to values
    ignore_missing:  If True, will not throw exception if a string contains a 
      tag not present in mapping, and will keep the tag instead.
  Returns:
    Object of the same type as obj, with strings formatted (tags replaced
    by their value)
  """
  def formatfn(x):
    fmt = SafeFormatter()
    formatz = (lambda x, m: x.format(**m)
               if not ignore_missing else fmt.format(x, **m))
    options = re.compile(r'{([^}]+):([^}]+)}')

    def mysub(match):
      options, thing = match.group(1, 2)
      ret = ''
      if 'a' in options:
        if ignore_missing and thing not in mapping:
          return match.group()
        else:
          word = formatz('{%s}' % thing, mapping)
          ret += '%s ' % add_article(word).split()[0]
      ret += '{%s}' % thing
      return ret

    x = options.sub(mysub, x)
    return formatz(x, mapping)

  return tree.map_structure(formatfn, obj)
Formats all strings within an object, using mapping
    
  Args:
    obj: Object (leaves must be strings, regardless of type)
    mapping: format dictionary, maps keys to values
    ignore_missing:  If True, will not throw exception if a string contains a 
      tag not present in mapping, and will keep the tag instead.
  Returns:
    Object of the same type as obj, with strings formatted (tags replaced
    by their value)
  
Formats all strings within an object, using mapping
Formats all strings within an object using mapping
def recursive_format(obj: TemplateObj, mapping: Dict,
                     ignore_missing: bool = False) -> TemplateObj:
  def formatfn(x):
    fmt = SafeFormatter()
    formatz = (lambda x, m: x.format(**m)
               if not ignore_missing else fmt.format(x, **m))
    options = re.compile(r'{([^}]+):([^}]+)}')
    def mysub(match):
      options, thing = match.group(1, 2)
      ret = ''
      if 'a' in options:
        if ignore_missing and thing not in mapping:
          return match.group()
        else:
          word = formatz('{%s}' % thing, mapping)
          ret += '%s ' % add_article(word).split()[0]
      ret += '{%s}' % thing
      return ret
    x = options.sub(mysub, x)
    return formatz(x, mapping)
  return tree.map_structure(formatfn, obj)
def recursive_format ( obj : TemplateObj , mapping : Dict , ignore_missing : bool = False ) -> TemplateObj : def formatfn ( x ) : fmt = SafeFormatter ( ) formatz = ( lambda x , m : x . format ( ** m ) if not ignore_missing else fmt . format ( x , ** m ) ) options = re . compile ( r'{([^}]+):([^}]+)}' ) def mysub ( match ) : options , thing = match . group ( 1 , 2 ) ret = '' if 'a' in options : if ignore_missing and thing not in mapping : return match . group ( ) else : word = formatz ( '{%s}' % thing , mapping ) ret += '%s ' % add_article ( word ) . split ( ) [ 0 ] ret += '{%s}' % thing return ret x = options . sub ( mysub , x ) return formatz ( x , mapping ) return tree . map_structure ( formatfn , obj )
Formats all strings within an object, using mapping
Formats all strings within an object using mapping
"""Formats all strings within an object, using mapping
    
  Args:
    obj: Object (leaves must be strings, regardless of type)
    mapping: format dictionary, maps keys to values
    ignore_missing:  If True, will not throw exception if a string contains a 
      tag not present in mapping, and will keep the tag instead.
  Returns:
    Object of the same type as obj, with strings formatted (tags replaced
    by their value)
  """
Object of the same type as obj, with strings formatted (tags replaced
by their value)
Object of the same type as obj with strings formatted ( tags replaced by their value )
obj
TemplateObj
Object (leaves must be strings, regardless of type)
Object ( leaves must be strings regardless of type )
mapping
Dict
format dictionary, maps keys to values
format dictionary maps keys to values
ignore_missing
bool
If True, will not throw exception if a string contains a
tag not present in mapping, and will keep the tag instead.
If True will not throw exception if a string contains a tag not present in mapping and will keep the tag instead .