MCPcopy Index your code
hub / github.com/bpython/bpython / get_encoding_file

Function get_encoding_file

bpython/inspection.py:373–381  ·  view source on GitHub ↗

Try to obtain encoding information from a Python source file.

(fname: str)

Source from the content-addressed store, hash-verified

371
372
373def get_encoding_file(fname: str) -> str:
374 """Try to obtain encoding information from a Python source file."""
375 with open(fname, encoding="ascii", errors="ignore") as f:
376 for _ in range(2):
377 line = f.readline()
378 match = _get_encoding_line_re.search(line)
379 if match:
380 return match.group(1)
381 return "utf8"
382
383
384def getattr_safe(obj: Any, name: str) -> Any:

Callers

nothing calls this directly

Calls 2

searchMethod · 0.80
readlineMethod · 0.45

Tested by

no test coverage detected