MCPcopy
hub / github.com/pex-tool/pex / to_bytes

Function to_bytes

pex/compatibility.py:61–68  ·  view source on GitHub ↗
(st, encoding="utf-8")

Source from the content-addressed store, hash-verified

59if PY2:
60
61 def to_bytes(st, encoding="utf-8"):
62 # type: (AnyStr, Text) -> bytes
63 if isinstance(st, unicode):
64 return st.encode(encoding)
65 elif isinstance(st, (str, bytes)):
66 return st
67 else:
68 raise ValueError("Cannot convert %s to bytes" % type(st))
69
70 def to_unicode(st, encoding="utf-8"):
71 # type: (AnyStr, Text) -> Text

Callers 10

compileMethod · 0.90
_prepare_codeMethod · 0.90
_build_zipappMethod · 0.90
test_to_bytesFunction · 0.90
write_sourceFunction · 0.90
test_iter_pth_pathsFunction · 0.90
test_clp_arg_fileFunction · 0.90
test_clp_preamble_fileFunction · 0.90

Calls 1

encodeMethod · 0.45

Tested by 7

test_to_bytesFunction · 0.72
write_sourceFunction · 0.72
test_iter_pth_pathsFunction · 0.72
test_clp_arg_fileFunction · 0.72
test_clp_preamble_fileFunction · 0.72