diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py index 9dab4c1c3a8880..7d74da00c1b53d 100644 --- a/Lib/urllib/robotparser.py +++ b/Lib/urllib/robotparser.py @@ -16,6 +16,8 @@ __all__ = ["RobotFileParser"] +req_rate = collections.namedtuple('req_rate', 'requests seconds') + class RobotFileParser: """ This class provides a set of methods to read, parse and answer questions about a single robots.txt file. @@ -136,11 +138,7 @@ def parse(self, lines): # check if all values are sane if (len(numbers) == 2 and numbers[0].strip().isdigit() and numbers[1].strip().isdigit()): - req_rate = collections.namedtuple('req_rate', - 'requests seconds') - entry.req_rate = req_rate - entry.req_rate.requests = int(numbers[0]) - entry.req_rate.seconds = int(numbers[1]) + entry.req_rate = req_rate(requests=int(numbers[0]), seconds=int(numbers[1])) state = 2 if state == 2: self._add_entry(entry)