MCPcopy Index your code
hub / github.com/python/cpython / _formatparam

Function _formatparam

Lib/wsgiref/headers.py:18–30  ·  view source on GitHub ↗

Convenience function to format and return a key=value pair. This will quote the value if needed or if quote is true.

(param, value=None, quote=1)

Source from the content-addressed store, hash-verified

16_value_disallowed_re = re.compile(r'[\x00-\x08\x0A-\x1F\x7F]')
17
18def _formatparam(param, value=None, quote=1):
19 """Convenience function to format and return a key=value pair.
20
21 This will quote the value if needed or if quote is true.
22 """
23 if value is not None and len(value) > 0:
24 if quote or tspecials.search(value):
25 value = value.replace('\\', '\\\\').replace('"', r'\"')
26 return '%s="%s"' % (param, value)
27 else:
28 return '%s=%s' % (param, value)
29 else:
30 return param
31
32
33class Headers:

Callers 1

add_headerMethod · 0.70

Calls 2

searchMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…