Пример #1
0
def json_fixup(obj):
  if isinstance(obj, RecipeConfigType):
    return str(obj)
  thawed = infra_types.thaw(obj)
  if thawed is not obj:  # i.e. it was a frozen type
    return thawed
  raise TypeError("%r is not JSON serializable" % obj)
Пример #2
0
  def set_val(self, val):
    if isinstance(val, ConfigBase):
      val = val.as_jsonish(include_hidden=True)
    if isinstance(val, infra_types.FrozenDict):
      val = infra_types.thaw(val)
    typeAssert(val, dict)

    val = dict(val)  # because we pop later.
    for name, config_obj in self._type_map.iteritems():
      if name in val:
        try:
          config_obj.set_val(val.pop(name))
        except Exception as e:
          raise Exception('While assigning key %r: %s' % (name, e))

    if val:
      raise TypeError("Got extra keys while setting ConfigGroup: %s" % val)
Пример #3
0
    def set_val(self, val):
        if isinstance(val, ConfigBase):
            val = val.as_jsonish(include_hidden=True)
        if isinstance(val, infra_types.FrozenDict):
            val = infra_types.thaw(val)
        typeAssert(val, dict)

        val = dict(val)  # because we pop later.
        for name, config_obj in self._type_map.iteritems():
            if name in val:
                try:
                    config_obj.set_val(val.pop(name))
                except Exception as e:
                    raise Exception('While assigning key %r: %s' % (name, e))

        if val:
            raise TypeError("Got extra keys while setting ConfigGroup: %s" %
                            val)
Пример #4
0
  def thaw(self):
    """Returns a vanilla python jsonish dictionary of properties."""

    return thaw(self._engine.properties)
Пример #5
0
    def thaw(self):
        """Returns a vanilla python jsonish dictionary of properties."""

        return thaw(self._engine.properties)