How to serialize this class back to yaml.
516417
def to_yaml(cls, representer, node):
        """"""
        return representer.represent_scalar(cls.yaml_tag, node.value)
960980
def save_yaml(self, outFile):
        """"""
        with open(outFile,'w') as myfile:
            print(yaml.dump(self.params), file=myfile)
1091757
def serialize(self):
        """"""
        api_metadata = OrderedDict()
        # $ char makes this come first in sort ordering
        api_metadata['$version'] = self.current_version
        locations = {}

        for svc_name, group in self.groups():
            group_apis = OrderedDict()
            group_metadata = OrderedDict()
            group_metadata['apis'] = group_apis
            group_metadata['title'] = group.title
            api_metadata[group.name] = group_metadata

            if group.docs is not None:
                group_metadata['docs'] = group.docs

            for name, api in group.items():
                group_apis[name] = OrderedDict()
                group_apis[name]['service'] = svc_name
                group_apis[name]['api_group'] = group.name
                group_apis[name]['api_name'] = api.name
                group_apis[name]['introduced_at'] = api.introduced_at
                group_apis[name]['methods'] = api.methods
                group_apis[name]['request_schema'] = api.request_schema
                group_apis[name]['response_schema'] = api.response_schema
                group_apis[name]['doc'] = api.docs
                group_apis[name]['changelog'] = api._changelog
                if api.title:
                    group_apis[name]['title'] = api.title
                else:
                    title = name.replace('-', ' ').replace('_', ' ').title()
                    group_apis[name]['title'] = title

                group_apis[name]['url'] = api.resolve_url()

                if api.undocumented:
                    group_apis[name]['undocumented'] = True
                if api.deprecated_at is not None:
                    group_apis[name]['deprecated_at'] = api.deprecated_at

                locations[name] = {
                    'api': api.location,
                    'request_schema': api._request_schema_location,
                    'response_schema': api._response_schema_location,
                    'changelog': api._changelog_locations,
                    'view': api.view_fn_location,
                }

        return api_metadata, locations
653193
def _get_serializable_model(cls):
        
        current_class = cls
        while current_class._meta.proxy:
            current_class = current_class._meta.proxy_for_model
        return current_class
645721
def write_yaml (self, data, encoding=None, errors=None, newline=None, **kwargs):
        
        import yaml

        with self.open (mode='wt', encoding=encoding, errors=errors, newline=newline) as f:
            return yaml.dump (data, stream=f, **kwargs)
1075893
def serialize(self, value, **kwargs):
        """"""
        kwargs.update({'include_class': kwargs.get('include_class', True)})
        if self.serializer is not None:
            return self.serializer(value, **kwargs)
        if value is None:
            return None
        serial_list = [self.prop.serialize(val, **kwargs)
                       for val in value]
        return serial_list
975048
def build_from_yamlstr(cls, yamlstr):
        
        top_dict = yaml.safe_load(yamlstr)
        coordsys = top_dict.pop('coordsys')
        output_list = []
        for e_key, e_dict in sorted(top_dict.items()):
            if e_key == 'coordsys':
                continue
            e_dict = top_dict[e_key]
            e_dict['coordsys'] = coordsys
            output_list += cls.build_from_energy_dict(e_key, e_dict)
        return output_list
332561
def dumps(self):
        
        return json.dumps([self.__class__.__name__.lower(), self._kwargs])
1185440
def _serialize(self, include_run_logs=False, strict_json=False):
        

        result = {'command': self.command,
                  'name': self.name,
                  'started_at': self.started_at,
                  'completed_at': self.completed_at,
                  'success': self.successful,
                  'soft_timeout': self.soft_timeout,
                  'hard_timeout': self.hard_timeout,
                  'hostname': self.hostname}

        if include_run_logs:
            last_run = self.backend.get_latest_run_log(self.parent_job.job_id,
                                                       self.name)
            if last_run:
                run_log = last_run.get('tasks', {}).get(self.name, {})
                if run_log:
                    result['run_log'] = run_log

        if strict_json:
            result = json.loads(json.dumps(result, cls=StrictJSONEncoder))
        return result
22524
public static DataAnalysis fromYaml(String yaml) {
        try{
            return new YamlSerializer().getObjectMapper().readValue(yaml, DataAnalysis.class);
        } catch (Exception e){
            //Legacy format
            ObjectMapper om = new YamlSerializer().getObjectMapper();
            return fromMapper(om, yaml);
        }
    }
303680
def deserialize(raw)
      begin
        case @serializer
        when :marshal
          Marshal.load(raw)
        when :json
          JSON.parse(raw, :create_additions => true)
        when :yaml
          YAML.load(raw)
        end
      rescue => e
        PEROBS.log.fatal "Cannot de-serialize object with #{@serializer} " +
          "parser: " + e.message
      end
    end
396999
def from_yaml(cls, path):
        """"""
        import yaml

        with path.open(mode='r') as fp:
            source = yaml.safe_load(fp) or {}
            self = cls.from_jsonld(
                source,
                __reference__=path,
                __source__=deepcopy(source),
            )

        return self
955659
def dump(config):
    

    return yaml.safe_dump(
        config.to_primitive(),
        default_flow_style=False,
        encoding='utf-8',
        allow_unicode=True)
894105
def serialize(self, obj, method='json', beautify=False, raise_exception=False):
        """"""

        return self.helper.string.serialization.serialize(
            obj=obj, method=method, beautify=beautify, raise_exception=raise_exception)
1155519
def as_yaml(self):
        
        dumped = dump(self.as_marked_up(), Dumper=StrictYAMLDumper, allow_unicode=True)
        return dumped if sys.version_info[0] == 3 else dumped.decode("utf8")
937053
def model_yaml(self, **kwargs):
        
        kwargs_copy = self.base_dict.copy()
        kwargs_copy.update(**kwargs)
        self._replace_none(kwargs_copy)        
        localpath = NameFactory.model_yaml_format.format(**kwargs_copy)
        if kwargs.get('fullpath', False):
            return self.fullpath(localpath=localpath)
        return localpath
983019
def YamlLoader(string):
  """"""
  representation = yaml.Parse(string)
  result_cls = aff4.FACTORY.AFF4Object(representation["aff4_class"])
  aff4_attributes = {}
  for predicate, values in iteritems(representation["attributes"]):
    attribute = aff4.Attribute.PREDICATES[predicate]
    tmp = aff4_attributes[attribute] = []

    for rdfvalue_cls_name, value, age in values:
      rdfvalue_cls = aff4.FACTORY.RDFValue(rdfvalue_cls_name)
      value = rdfvalue_cls(value, age=rdfvalue.RDFDatetime(age))
      tmp.append(value)

  # Ensure the object is dirty so when we save it, it can be written to the data
  # store.
  result = result_cls(
      urn=representation["_urn"],
      clone=aff4_attributes,
      mode="rw",
      age=representation["age_policy"])

  result.new_attributes, result.synced_attributes = result.synced_attributes, {}

  result._dirty = True  # pylint: disable=protected-access

  return result