MCPcopy
hub / github.com/Nuitka/Nuitka / getFileContents

Function getFileContents

nuitka/utils/FileOperations.py:1124–1140  ·  view source on GitHub ↗

Get the contents of a file. Args: filename: str with the file to be read mode: "r" for str, "rb" for bytes result encoding: optional encoding to used when reading the file, e.g. "utf8" errors: optional error handler decoding the content, as defined in `codecs`

(filename, mode="r", encoding=None, errors=None)

Source from the content-addressed store, hash-verified

1122
1123
1124def getFileContents(filename, mode="r", encoding=None, errors=None):
1125 """Get the contents of a file.
1126
1127 Args:
1128 filename: str with the file to be read
1129 mode: "r" for str, "rb" for bytes result
1130 encoding: optional encoding to used when reading the file, e.g. "utf8"
1131 errors: optional error handler decoding the content, as defined in `codecs`
1132
1133 Returns:
1134 str or bytes - depending on mode.
1135
1136 """
1137
1138 with withFileLock("reading file %s" % filename):
1139 with openTextFile(filename, mode, encoding=encoding, errors=errors) as f:
1140 return f.read()
1141
1142
1143def stripFileContentsBOM(contents):

Callers 15

executePostProcessingFunction · 0.90
checkAtHomeFunction · 0.90
syncTimeFunction · 0.90
attachLeadingCommentFunction · 0.90
checkRstLintFunction · 0.90
_fixupManPageContentsFunction · 0.90
mainFunction · 0.90
runCodespellFunction · 0.90
cleanupRstFmtFunction · 0.90

Calls 3

withFileLockFunction · 0.85
openTextFileFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…