def shortvals_to_str(shortvals):
  '''
  Convert [("key1", "val1"), ("key2", "val2")] or {"key1": "val1", "key2": "val2"} to "key1=val1;key2=val2".
  Values that are None are skipped.
  '''
  if type(shortvals) == dict:
    shortvals = [(k, shortvals[k]) for k in sorted(shortvals)]
  for (k, v) in shortvals:
    if ";" in str(k) or "=" in str(k) or (v is not None and (";" in str(v) or "=" in str(v))):
      raise InvalidArgument("invalid shortval string: '%s'" % shortvals)
  # XXX we cannot use str(float) since it truncates lower digits, especially on linux
  return ";".join(["%s=%s" % (str(k), v % "%f" if isinstance(v, float) else str(v)) for (k,v) in shortvals if v is not None])
dataset/ETHPy150Open bloomreach/zinc/zinc.py/shortvals_to_str/swapped operands of `%`