def sub(self, s, **kargs):
    if not isinstance(s, basestring):
      if isinstance(s, list):
        # Recursively substitute variables for each list elements.
        return [self.sub(l, **kargs) for l in s]
      else:
        return s

    def lookup(match):
      '''Lookup function for regex substitution.'''
      key = match.group(1)
      if key in kargs:
        value = kargs[key]
      else:
        value = self.__getitem__(key)
      if value is not None:
        return str(value)
      return '${%s}' % key

    return Properties.var_pattern.sub(lookup, s)
Utility function to substitute variables with value.
dataset/ETHPy150Open bloomreach/briefly/src/briefly/properties.py/Properties.sub