Pre-serialisation of the meta data
167776
def as_dict(self):
        
        drepr = {}
        drepr["name"] = self.name
        drepr["time"] = self.time
        # error pre-serialisation
        drepr["errors"] = [str(err) for err in self.errors]
        # warning  pre-serialisation
        drepr["warnings"] = [str(warn) for warn in self.warnings]
        return drepr
1084813
def generatemetadata(self, parameters, parentfile, relevantinputfiles, provenancedata = None):
        """"""
        assert isinstance(provenancedata,CLAMProvenanceData) or provenancedata is None

        data = {}

        if self.copymetadata:
            #Copy parent metadata
            for key, value in parentfile.metadata.items():
                data[key] = value

        for metafield in self.metafields:
            if isinstance(metafield, ParameterCondition):
                metafield = metafield.evaluate(parameters)
                if not metafield:
                    continue
            assert isinstance(metafield, AbstractMetaField)
            metafield.resolve(data, parameters, parentfile, relevantinputfiles)

        if provenancedata:
            data['provenance'] = provenancedata

        return self.formatclass(None, **data)
1250479
def dump(self):
        """"""
        metadata = dict()
        for attr in sorted(self.datastore):
            # Initialise the attribute (e.g. sample.general) key in the metadata dictionary
            metadata[attr] = dict()
            # Ignore attributes that begin with '__'
            if not attr.startswith('__'):
                # If self.datastore[attribute] is a primitive datatype, populate the metadata dictionary with
                # the attr: self.datastore[attr] pair
                # e.g. attr: name,  self.datastore[attr]: 2013-SEQ-0072
                if isinstance(self.datastore[attr], str) or \
                        isinstance(self.datastore[attr], list) or \
                        isinstance(self.datastore[attr], dict) or \
                        isinstance(self.datastore[attr], int):
                    metadata[attr] = self.datastore[attr]
                else:
                    # Otherwise, recursively convert GenObjects to nested dictionaries
                    metadata.update(self.nested_genobject(metadata, attr, self.datastore))
        return metadata
446116
function initMetadataConversions() {
  var mdc = this.metadataConversions

  mdc['publish'] = {
    deserialize: function (dateString) {
      if (dateString)
        return new Date(Date.parse(dateString))
      else
        return dateString
    },
    serialize: function (date) {
      if (date instanceof Date) {
        return date.getFullYear() + '-' 
          + ('0' + (date.getMonth()+1)).slice(-2) + '-'
          + ('0' + date.getDate())
      } else {
        return date.toString()
      }
    }
  }

  mdc['tags'] = {
    deserialize: function (tagString) { //prob not very readable
      if (S(tagString).contains(',')) return tagString.split(',').map(function(tag){ return tag.trim() })
      //else if (S(tagString).contains(' ')) return tagString.split(' ').map(function(tag){ return tag.trim() })
      else return [tagString]
    },
    serialize: function (tagArray) {
      return tagArray.join(', ')
    }
  }
}
236340
def transport_meta_data(self):
        """"""

        # For each packet in the pcap process the contents
        for item in self.input_stream:

            # Get the transport data and type
            trans_data = item['packet']['data']
            trans_type = self._get_transport_type(trans_data)
            if trans_type and trans_data:
                item['transport'] = data_utils.make_dict(trans_data)
                item['transport']['type'] = trans_type
                item['transport']['flags'] = self._readable_flags(item['transport'])
                item['transport']['data'] = trans_data['data']

            # All done
            yield item
210625
def prep_for_deserialize(model, record, using, init_list=None):  # pylint:disable=unused-argument
    
    # TODO the parameter 'using' is not currently important.
    attribs = record.pop('attributes')  # NOQA pylint:disable=unused-variable

    mod = model.__module__.split('.')
    if hasattr(model._meta, 'app_label'):
        app_label = getattr(model._meta, 'app_label')
    elif mod[-1] == 'models':
        app_label = mod[-2]
    else:
        raise ImproperlyConfigured("Can't discover the app_label for %s, you must specify it via model meta options.")

    if len(record.keys()) == 1 and model._meta.db_table in record:
        # this is for objects with ManyToManyField and OneToOneField
        while len(record) == 1:
            record = list(record.values())[0]
            if record is None:
                return None

    fields = prep_for_deserialize_inner(model, record, init_list=init_list)

    if init_list and set(init_list).difference(fields).difference([SF_PK]):
        raise DatabaseError("Not found some expected fields")

    return dict(
        model='.'.join([app_label, model.__name__]),
        pk=record.pop('Id'),
        fields=fields,
    )
1288953
def pre_serialize(self, raw, pkt, i):
        '''
        
        '''
        self.length = len(raw) + OpenflowHeader._MINLEN
218803
def convert_meta(self):
        
        meta_ = DS9Parser.parse_meta(self.meta_str)
        self.meta = copy.deepcopy(self.global_meta)
        self.meta.update(meta_)
        # the 'include' is not part of the metadata string;
        # it is pre-parsed as part of the shape type and should always
        # override the global one
        self.include = self.meta.get('include', True) if self.include == '' else self.include != '-'
        self.meta['include'] = self.include
22774
def get_mapping(self, meta_fields=True):
        '''
        
        '''
        return {'properties': dict((name, field.json()) for name, field in iteritems(self.fields) if meta_fields or name not in AbstractField.meta_fields)}
670460
public byte[] toBinary(Object value, Object meta, boolean insertMeta) {
		return serialize(value, meta, insertMeta);
	}
633887
protected void writeMetadata() throws IOException {
    Set<GlobalMetadata> collectedMetadata = metadataCollector.getMetadataRecords();

    if (collectedMetadata.isEmpty()) {
      return;
    }

    String propName =
        ForkOperatorUtils.getPropertyNameForBranch(ConfigurationKeys.WRITER_METADATA_KEY, numBranches, branchId);
    String metadataStr;
    if (collectedMetadata.size() == 1) {
      metadataStr = collectedMetadata.iterator().next().toJson();
    } else {
      StringBuilder sb = new StringBuilder();
      sb.append('[');
      boolean first = true;

      for (GlobalMetadata md : collectedMetadata) {
        if (!first) {
          sb.append(',');
        }
        sb.append(md.toJson());
        first = false;
      }
      sb.append(']');
      metadataStr = sb.toString();
    }

    this.properties.setProp(propName, metadataStr);
  }
430404
def serialize(self, resources):
        """"""
        serialized = {
            'meta': {
                'sqlalchemy_jsonapi_version': '4.0.9'
            },
            'jsonapi': {
                'version': '1.0'
            }
        }
        # Determine multiple resources by checking for SQLAlchemy query count.
        if hasattr(resources, 'count'):
            serialized['data'] = []
            for resource in resources:
                serialized['data'].append(
                    self._render_resource(resource))
        else:
            serialized['data'] = self._render_resource(resources)

        return serialized
599543
function build_meta_information(object) {
      var res = {
        "timestamp": object.timestamp,
        "version": object.version,
        "changeset": object.changeset,
        "user": object.user,
        "uid": object.uid
      };
      for (var k in res)
        if (res[k] === undefined)
          delete res[k];
      return res;
    }
897206
def save_output_meta(self):
        
        options = self.options
        file_path = os.path.join(options.outputdir, 'output.meta.json')
        with open(file_path, 'w') as outfile:
            json.dump(self.OUTPUT_META_DICT, outfile)
101836
def serialize(self, content):
        
        worker = XMLSerializer(
            scheme=self.resource,
            format=self.resource._meta.emit_format,
            options=self.resource._meta.emit_options,
            **self.resource._meta.emit_models
        )
        return self.xmldoc_tpl % (
            'true' if not self.response.error else 'false',
            str(self.resource.api or ''),
            int(mktime(datetime.now().timetuple())),
            worker.serialize(content)
        )
1374097
def Serialize(self, val, info):
      
      self._Serialize(val, info, self.defaultNS)
53878
def serialize_rdf(update_graph, signing):
    '''
    '''
    unsorted_s = update_graph.serialize(format = 'pretty-xml')
    unsorted_s = unsorted_s.replace('xmlns:rdf', 'xmlns:RDF')
    unsorted_s = unsorted_s.replace('rdf:', 'RDF:')
    unsorted_s = unsorted_s.replace('RDF:about', 'about')
    unsorted_s = unsorted_s.split('\n')
    start, end = unsorted_s[0:5], unsorted_s[-2:]
    unsorted_s = unsorted_s[5:-2]
    if signing:
        unsorted_s = [line[2:] for line in unsorted_s]
        unsorted_s.append('')
    sorting_s = []
    prev_leading_spaces = -2
    for line in unsorted_s:
        leading_spaces = len(line) - len(line.lstrip())
        if leading_spaces > prev_leading_spaces:
            sorting_s.append([line])
        elif leading_spaces == prev_leading_spaces:
            sorting_s[-1].append(line)
        elif leading_spaces < prev_leading_spaces:
            tmp_line = sorting_s.pop()
            tmp_line = '\n'.join(sorted(tmp_line))
            tmp_line = [sorting_s[-1].pop(), tmp_line, line]
            tmp_line = '\n'.join(tmp_line)
            sorting_s[-1].append(tmp_line)
        prev_leading_spaces = leading_spaces
    if signing:
        sorted_s = '\n'.join(sorting_s[0])
    else:
        sorted_s = []
        sorted_s.extend(start)
        sorted_s.extend(sorting_s[0])
        sorted_s.extend(end)
        sorted_s = '\n'.join(sorted_s)
    return sorted_s