MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _metadata_to_str

Function _metadata_to_str

lib/matplotlib/backends/backend_pgf.py:149–166  ·  view source on GitHub ↗

Convert metadata key/value to a form that hyperref accepts.

(key, value)

Source from the content-addressed store, hash-verified

147
148
149def _metadata_to_str(key, value):
150 """Convert metadata key/value to a form that hyperref accepts."""
151 if isinstance(value, datetime.datetime):
152 value = _datetime_to_pdf(value)
153 elif key == 'Trapped':
154 value = value.name.decode('ascii')
155 else:
156 value = str(value)
157
158 # ensure that metadata does not contain special TeX chars because we
159 # insert the metadata as raw text into the TeX source
160 invalid_chars = r"\{}[]()"
161 if any(c in value + key for c in invalid_chars):
162 raise ValueError(
163 f"Invalid metadata value for {key!r}: {value!r}. "
164 f"The value must not contain the chars {invalid_chars}.")
165
166 return f'{key}={{{value}}}'
167
168
169def make_pdf_to_png_converter():

Callers 4

test__metadata_to_strFunction · 0.90
print_pdfMethod · 0.85
_write_headerMethod · 0.85

Calls 1

_datetime_to_pdfFunction · 0.90

Tested by 2

test__metadata_to_strFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…