MCPcopy Create free account
hub / github.com/ahupp/python-magic / maybe_decode

Function maybe_decode

magic/__init__.py:232–239  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

230# return str on python3. Don't want to unconditionally
231# decode because that results in unicode on python2
232def maybe_decode(s):
233 # NEXTBREAK: remove
234 if str == bytes:
235 return s
236 else:
237 # backslashreplace here because sometimes libmagic will return metadata in the charset
238 # of the file, which is unknown to us (e.g the title of a Word doc)
239 return s.decode('utf-8', 'backslashreplace')
240
241
242try:

Callers 3

from_bufferMethod · 0.85
from_fileMethod · 0.85
from_descriptorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…