Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
73f570ba
Commit
73f570ba
authored
Mar 18, 2002
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly set default entry in all cases.
parent
d22368ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
Lib/robotparser.py
Lib/robotparser.py
+9
-6
No files found.
Lib/robotparser.py
View file @
73f570ba
...
...
@@ -58,6 +58,13 @@ class RobotFileParser:
_debug
(
"parse lines"
)
self
.
parse
(
lines
)
def
_add_entry
(
self
,
entry
):
if
"*"
in
entry
.
useragents
:
# the default entry is considered last
self
.
default_entry
=
entry
else
:
self
.
entries
.
append
(
entry
)
def
parse
(
self
,
lines
):
"""parse the input lines from a robot.txt file.
We allow that a user-agent: line is not preceded by
...
...
@@ -76,11 +83,7 @@ class RobotFileParser:
entry
=
Entry
()
state
=
0
elif
state
==
2
:
if
"*"
in
entry
.
useragents
:
# the default entry is considered last
self
.
default_entry
=
entry
else
:
self
.
entries
.
append
(
entry
)
self
.
_add_entry
(
entry
)
entry
=
Entry
()
state
=
0
# remove optional comment and strip line
...
...
@@ -99,7 +102,7 @@ class RobotFileParser:
_debug
(
"line %d: warning: you should insert a blank"
" line before any user-agent"
" directive"
%
linenumber
)
self
.
entries
.
append
(
entry
)
self
.
_add_entry
(
entry
)
entry
=
Entry
()
entry
.
useragents
.
append
(
line
[
1
])
state
=
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment