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

Method read

Lib/urllib/robotparser.py:74–86  ·  view source on GitHub ↗

Reads the robots.txt URL and feeds it to the parser.

(self)

Source from the content-addressed store, hash-verified

72 self.host, self.path = urllib.parse.urlsplit(url)[1:3]
73
74 def read(self):
75 """Reads the robots.txt URL and feeds it to the parser."""
76 try:
77 f = urllib.request.urlopen(self.url)
78 except urllib.error.HTTPError as err:
79 if err.code in (401, 403):
80 self.disallow_all = True
81 elif err.code >= 400 and err.code < 500:
82 self.allow_all = True
83 err.close()
84 else:
85 raw = f.read()
86 self.parse(raw.decode("utf-8", "surrogateescape").splitlines())
87
88 def _add_entry(self, entry):
89 if "*" in entry.useragents:

Callers 6

testReadMethod · 0.95
test_read_404Method · 0.95
_read_side_effectFunction · 0.45
urlretrieveFunction · 0.45
http_error_302Method · 0.45

Calls 5

parseMethod · 0.95
urlopenMethod · 0.45
closeMethod · 0.45
splitlinesMethod · 0.45
decodeMethod · 0.45

Tested by 3

testReadMethod · 0.76
test_read_404Method · 0.76