MCPcopy Index your code
hub / github.com/python/cpython / readfp

Method readfp

Lib/mimetypes.py:250–268  ·  view source on GitHub ↗

Read a single mime.types-format file. If strict is true, information will be added to list of standard types, else to the list of non-standard types.

(self, fp, strict=True)

Source from the content-addressed store, hash-verified

248 self.readfp(fp, strict)
249
250 def readfp(self, fp, strict=True):
251 """
252 Read a single mime.types-format file.
253
254 If strict is true, information will be added to
255 list of standard types, else to the list of non-standard
256 types.
257 """
258 while line := fp.readline():
259 words = line.split()
260 for i in range(len(words)):
261 if words[i][0] == '#':
262 del words[i:]
263 break
264 if not words:
265 continue
266 type, suffixes = words[0], words[1:]
267 for suff in suffixes:
268 self.add_type(type, '.' + suff, strict)
269
270 def read_windows_registry(self, strict=True):
271 """

Callers 3

readMethod · 0.95
read_mime_typesFunction · 0.95
test_file_parsingMethod · 0.80

Calls 3

add_typeMethod · 0.95
readlineMethod · 0.45
splitMethod · 0.45

Tested by 1

test_file_parsingMethod · 0.64