Convert non-string metadata values to strings and drop null values
428252
def sanitize_metadata(self, metadata, replace_hyphen_with="-"):
        """"""
        return {str(k).replace("-", replace_hyphen_with): str(v)
                for k, v in (metadata or {}).items() if v is not None}
267707
function encodeMetadataException(type) {
	if (type === "metadata") {
		return exceptions.METADATA;
	} else if (type === "access") {
		return exceptions.ACCESS;
	} else if (type === "credits") {
		return exceptions.CREDITS;
	} else if (type === "conflictingSession") {
		return exceptions.CONFLICTING_SESSION;
	} else if (type === "items") {
		return exceptions.ITEMS;
	} else if (type === "schema") {
		return exceptions.SCHEMA;
	} else if (type === "notification") {
		return exceptions.NOTIFICATION;
	} else {
		return exceptions.GENERIC;
	}
}
1366310
private String dataToString( Object data ) {
        if ( data == null ) return "<null>";
        return ( data instanceof Scriptable ) ? ScriptableUtils.toString((Scriptable) data)
                                              : Objects.toString(data);
    }
332898
function filterOutNullData(fieldValues) {
  return _.filter(fieldValues || [], function(val) {
    return val === false || val === 0 || val;
  });
}
1142111
protected void generateMetadata(IXmlStyleAppendable it) {
		it.appendTagWithValue("property", //$NON-NLS-1$
				Strings.concat(";", getMimeTypes()), //$NON-NLS-1$
				"name", "mimetypes"); //$NON-NLS-1$ //$NON-NLS-2$

		final StringBuilder buffer = new StringBuilder();
		for (final String fileExtension : getLanguage().getFileExtensions()) {
			if (buffer.length() > 0) {
				buffer.append(";"); //$NON-NLS-1$
			}
			buffer.append("*.").append(fileExtension); //$NON-NLS-1$
		}
		it.appendTagWithValue("property", //$NON-NLS-1$
				buffer.toString(),
				"name", "globs"); //$NON-NLS-1$ //$NON-NLS-2$

		it.appendTagWithValue("property", //$NON-NLS-1$
				"//", //$NON-NLS-1$
				"name", "line-comment-start"); //$NON-NLS-1$ //$NON-NLS-2$

		it.appendTagWithValue("property", //$NON-NLS-1$
				"/*", //$NON-NLS-1$
				"name", "block-comment-start"); //$NON-NLS-1$ //$NON-NLS-2$

		it.appendTagWithValue("property", //$NON-NLS-1$
				"*/", //$NON-NLS-1$
				"name", "block-comment-end"); //$NON-NLS-1$ //$NON-NLS-2$
	}
87475
def dump(self, fields=None, exclude=None):
        
        exclude = exclude or []
        d = {}
        if fields and self._primary_field not in fields:
            fields = list(fields)
            fields.append(self._primary_field)
        for k, v in self.properties.items():
            if ((not fields) or (k in fields)) and (not exclude or (k not in exclude)):
                if not isinstance(v, ManyToMany):
                    t = v.get_value_for_datastore(self)
                    if t is Lazy:
                        self.refresh()
                        t = v.get_value_for_datastore(self)
                    if isinstance(t, Model):
                        t = t._key
                    d[k] = v.to_str(t)
                else:
                    if fields:
                       d[k] = ','.join([str(x) for x in getattr(self, v._lazy_value(), [])])
        if self._primary_field and d and self._primary_field not in d:
            d[self._primary_field] = str(self._key)
        return d
1058765
def _convert_nonstring_categoricals(self, param_dict):
        """"""
        return {name: (self.categorical_mappings_[name][val] if name in self.categorical_mappings_ else val)
                for (name, val) in param_dict.items()}
328129
function extractMetadata (content, callback) {
  var end;
  var result;
  var metadata = '';
  var body = content;

  // Metadata is defined by either starting and ending line,
  if (content.slice(0, 3) === '---') {
    result = content.match(/^-{3,}\s([\s\S]*?)-{3,}(\s[\s\S]*|\s?)$/);
    if (result && result.length === 3) {
      metadata = result[1];
      body = result[2];
    }
  }
  // or Markdown metadata section at beginning of file.
  else if (content.slice(0, 12) === '```metadata\n') {
    end = content.indexOf('\n```\n');
    if (end !== -1) {
      metadata = content.substring(12, end);
      body = content.substring(end + 5);
    }
  }

  parseMetadata(metadata, function (error, parsed) {
    if (error) return callback(error);
    callback(null, {
      metadata: parsed,
      body: body
    });
  });
}
173555
def parse_metadata_string(metadata_string):
        """"""
        regex = r"STOP_DATE.+?VALUE\s*=\s*\"(.+?)\""
        match = re.search(regex, metadata_string, re.DOTALL)
        end_time_str = match.group(1)
        return end_time_str
259228
def replace_nulls(hdrs):
        """"""
        ret = []
        idx = 0
        for hdr in hdrs:
            if hdr == '':
                ret.append("no_hdr{}".format(idx))
            else:
                ret.append(hdr)
        return ret
690129
def to_dc(data):
    
    root = odict[
        "metadata": odict[
            "@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
            "@xmlns:dc": "http://purl.org/dc/elements/1.1/",
            "@xmlns:dcterms": "http://purl.org/dc/terms/",
            "@xmlns:rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        ]
    ]

    # map metadata to the root element, skip None values
    for key, val in _convert_metadata(_remove_none(data)).iteritems():
        if val is None:
            continue

        if isinstance(val, basestring) and not val.strip():
            continue

        if isinstance(val, str):
            val = val.decode("utf-8")

        root["metadata"][key] = val

    return unparse(root, pretty=True, indent="    ")
807548
public static String encodeMetadata(ServiceEndpoint serviceEndpoint) {
    try {
      return objectMapper.writeValueAsString(serviceEndpoint);
    } catch (IOException e) {
      LOGGER.error("Failed to write metadata: " + e);
      throw Exceptions.propagate(e);
    }
  }
1162759
def _clean_metadata(self):
        
        desc = self.metadata.get_long_description()
        if not isinstance(desc, six.text_type):
            desc = desc.decode('utf-8')
        lines = io.StringIO(desc)

        def trim_eight_spaces(line):
            if line.startswith(' ' * 8):
                line = line[8:]
            return line
        lines = itertools.chain(
            itertools.islice(lines, 1),
            six.moves.map(trim_eight_spaces, lines),
        )
        self.metadata.long_description = ''.join(lines)
456768
def metadata_to_md_options(metadata):
    

    return ' '.join(["{}={}".format(key, dumps(metadata[key]))
                     if metadata[key] is not None else key for key in metadata])
767540
public static String serializeMetaData(Map<String, List<String>> metaData) {
        StringBuilder buf = new StringBuilder();
        if (metaData != null && metaData.size() > 0) {
            buf.append("<metadata xmlns=\"http://jivesoftware.com/protocol/workgroup\">");
            for (String key : metaData.keySet()) {
                List<String> value = metaData.get(key);
                for (String v : value) {
                    buf.append("<value name=\"").append(key).append("\">");
                    buf.append(StringUtils.escapeForXmlText(v));
                    buf.append("</value>");
                }
            }
            buf.append("</metadata>");
        }
        return buf.toString();
    }
425593
def make_val(clas,*vals):
    ""
    if clas.VALUE is None: raise TypeError('null meta-information in class for VALUE')
    clas.type_check(zip(*clas.VALUE)[1],vals,'VALUE')
    return msgpack.dumps(vals)
784104
function parseMetadata (source, callback) {
  var i;
  var lines;
  var markerPad = '';

  if (!source) return callback(null, {});
  if (source.length === 0) return callback(null, {});

  try {
    return callback(null, yaml.load(source) || {});
  }
  catch (error) {
    if (error.problem != null && error.problemMark != null) {
      lines = error.problemMark.buffer.split('\n');
      for (i = 0; i < error.problemMark.column; i++) {
        markerPad += ' ';
      }
      error.message = "YAML: " + error.problem + "\n\n"
        + lines[error.problemMark.line] + "\n" + markerPad + "^\n";
    }
    else {
      error.message = "YAML Parsing error " + error.message;
    }
    return callback(error);
  }
}