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
5b104b9e
Commit
5b104b9e
authored
Jul 09, 2012
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Plain Diff
Merged upstream changes.
parents
39cf6d6e
27b0c88c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
Tools/scripts/highlight.py
Tools/scripts/highlight.py
+9
-1
No files found.
Tools/scripts/highlight.py
View file @
5b104b9e
...
...
@@ -10,7 +10,7 @@ import keyword, tokenize, cgi, functools
def
is_builtin
(
s
):
'Return True if s is the name of a builtin'
return
s
in
vars
(
__builtins__
)
return
hasattr
(
__builtins__
,
s
)
def
combine_range
(
lines
,
start
,
end
):
'Join content from a range of lines between start and end'
...
...
@@ -161,6 +161,8 @@ if __name__ == '__main__':
help
=
'build a complete html webpage'
)
parser
.
add_argument
(
'-s'
,
'--section'
,
action
=
'store_true'
,
help
=
'show an HTML section rather than a complete webpage'
)
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
'store_true'
,
help
=
'display categorized text to stderr'
)
args
=
parser
.
parse_args
()
if
args
.
section
and
(
args
.
browser
or
args
.
complete
):
...
...
@@ -172,6 +174,12 @@ if __name__ == '__main__':
source
=
f
.
read
()
classified_text
=
analyze_python
(
source
)
if
args
.
verbose
:
classified_text
=
list
(
classified_text
)
for
line_upto_token
,
kind
,
line_thru_token
in
classified_text
:
sys
.
stderr
.
write
(
'%15s: %r
\
n
'
%
(
'leadin'
,
line_upto_token
))
sys
.
stderr
.
write
(
'%15s: %r
\
n
\
n
'
%
(
kind
,
line_thru_token
))
if
args
.
complete
or
args
.
browser
:
encoded
=
build_html_page
(
classified_text
,
title
=
sourcefile
)
elif
args
.
section
:
...
...
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