Ejemplo n.º 1
0
  def recover(self, s, storage_keys=None):
    """Attempt to replace any placeholder substring with its original string. If
    `storage_keys` is specified, it will only look into the specified keys.

    Args:
      s: String to recover
      storage_keys: Specific storage keys to look into (default: {None})

    Returns:
      Recovered string
      str
    """
    if storage_keys is None:
      storage_keys = self.__data.keys()
    for n in storage_keys:
      key = Util.f(n)
      if key not in s:
        continue
      s = s.replace(key, self.recover(self.__data.pop(n)))
    return s
Ejemplo n.º 2
0
  def recover(self, s, storage_keys=None):
    """Attempt to replace any placeholder substring with its original string. If
    `storage_keys` is specified, it will only look into the specified keys.

    Args:
      s: String to recover
      storage_keys: Specific storage keys to look into (default: {None})

    Returns:
      Recovered string
      str
    """
    if storage_keys is None:
      storage_keys = self.__data.keys()
    for n in storage_keys:
      key = Util.f(n)
      if key not in s:
        continue
      s = s.replace(key, self.recover(self.__data.pop(n)))
    return s
Ejemplo n.º 3
0
 def _format_key(cls, n):
     return Util.f(n)
Ejemplo n.º 4
0
 def _format_key(cls, n):
   return Util.f(n)
Ejemplo n.º 5
0
 def _format_key(self, n):
   self._storage_keys.add(n)
   return Util.f(n)