MCPcopy Index your code
hub / github.com/KhronosGroup/Vulkan-Docs / loadFile

Function loadFile

scripts/reflib.py:238–253  ·  view source on GitHub ↗

Load a file into a list of strings. Return the (list, newline_string) or (None, None) on failure

(filename)

Source from the content-addressed store, hash-verified

236 return pi
237
238def loadFile(filename):
239 """Load a file into a list of strings. Return the (list, newline_string) or (None, None) on failure"""
240 newline_string = "\n"
241 try:
242 with open(filename, 'rb') as fp:
243 contents = fp.read()
244 if contents.count(b"\r\n") > 1:
245 newline_string = "\r\n"
246
247 with open(filename, 'r', encoding='utf-8') as fp:
248 lines = fp.readlines()
249 except:
250 logWarn(f'Cannot open file {filename} : {sys.exc_info()[0]}')
251 return None, None
252
253 return lines, newline_string
254
255def clampToBlock(line, minline, maxline):
256 """Clamp a line number to be in the range [minline,maxline].

Callers 10

genRefFunction · 0.90
findDuplicateWordsFunction · 0.90
match_with_expectedFunction · 0.90
populateMethod · 0.90
antora-prep.pyFile · 0.90
reflowFileFunction · 0.90
promoteFileFunction · 0.85
insertTagsFunction · 0.85
findBalanceFunction · 0.85
replaceRefFunction · 0.85

Calls 1

logWarnFunction · 0.85

Tested by 1

match_with_expectedFunction · 0.72