Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cf6eac40
Kaydet (Commit)
cf6eac40
authored
Tem 03, 2012
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Minor cleanups
üst
ecea0fb1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
README
Tools/scripts/README
+1
-1
highlight.py
Tools/scripts/highlight.py
+10
-10
No files found.
Tools/scripts/README
Dosyayı görüntüle @
cf6eac40
...
...
@@ -28,6 +28,7 @@ ftpmirror.py FTP mirror script
google.py Open a webbrowser with Google
gprof2html.py Transform gprof(1) output into useful HTML
h2py.py Translate #define's into Python assignments
highlight.py Python syntax highlighting with HTML output
idle3 Main program to start IDLE
ifdef.py Remove #if(n)def groups from C sources
lfcr.py Change LF line endings to CRLF (Unix to Windows)
...
...
@@ -47,7 +48,6 @@ pdeps.py Print dependencies between Python modules
pickle2db.py Load a pickle generated by db2pickle.py to a database
pindent.py Indent Python code, giving block-closing comments
ptags.py Create vi tags file for Python modules
pycolorize.py Python syntax highlighting with HTML output
pydoc3 Python documentation browser
pysource.py Find Python source files
redemo.py Basic regular expression demonstration facility
...
...
Tools/scripts/
pycolorize
.py
→
Tools/scripts/
highlight
.py
Dosyayı görüntüle @
cf6eac40
...
...
@@ -21,7 +21,7 @@ def escape_range(lines, start, end):
def
colorize
(
source
):
'Convert Python source code to an HTML fragment with colorized markup'
lines
=
source
.
splitlines
(
True
)
lines
=
source
.
splitlines
(
keepends
=
True
)
lines
.
append
(
''
)
readline
=
functools
.
partial
(
next
,
iter
(
lines
),
''
)
kind
=
tok_str
=
''
...
...
@@ -31,7 +31,7 @@ def colorize(source):
for
tok
in
tokenize
.
generate_tokens
(
readline
):
prev_tok_type
,
prev_tok_str
=
tok_type
,
tok_str
tok_type
,
tok_str
,
(
srow
,
scol
),
(
erow
,
ecol
),
logical_lineno
=
tok
kind
,
prev_kind
=
''
,
kind
kind
=
''
if
tok_type
==
tokenize
.
COMMENT
:
kind
=
'comment'
elif
tok_type
==
tokenize
.
OP
and
tok_str
[:
1
]
not
in
'{}[](),.:;'
:
...
...
@@ -102,22 +102,22 @@ if __name__ == '__main__':
import
sys
,
argparse
,
webbrowser
,
os
parser
=
argparse
.
ArgumentParser
(
description
=
'Convert Python source code to colorized HTML'
)
parser
.
add_argument
(
'sourcefile'
,
metavar
=
'SOURCEFILE'
,
nargs
=
1
,
description
=
'Convert Python source code to colorized HTML'
)
parser
.
add_argument
(
'sourcefile'
,
metavar
=
'SOURCEFILE'
,
help
=
'File containing Python sourcecode'
)
parser
.
add_argument
(
'-b'
,
'--browser'
,
action
=
'store_true'
,
help
=
'launch a browser to show results'
)
parser
.
add_argument
(
'-s'
,
'--s
tandalone
'
,
action
=
'store_true'
,
help
=
'show a
standalone snippet
rather than a complete webpage'
)
parser
.
add_argument
(
'-s'
,
'--s
ection
'
,
action
=
'store_true'
,
help
=
'show a
n HTML section
rather than a complete webpage'
)
args
=
parser
.
parse_args
()
if
args
.
browser
and
args
.
s
tandalone
:
parser
.
error
(
'The -s/--s
tandalone
option is incompatible with '
if
args
.
browser
and
args
.
s
ection
:
parser
.
error
(
'The -s/--s
ection
option is incompatible with '
'the -b/--browser option'
)
sourcefile
=
args
.
sourcefile
[
0
]
sourcefile
=
args
.
sourcefile
with
open
(
sourcefile
)
as
f
:
page
=
f
.
read
()
html
=
colorize
(
page
)
if
args
.
s
tandalone
else
build_page
(
page
,
title
=
sourcefile
)
html
=
colorize
(
page
)
if
args
.
s
ection
else
build_page
(
page
,
title
=
sourcefile
)
if
args
.
browser
:
htmlfile
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
sourcefile
))[
0
]
+
'.html'
with
open
(
htmlfile
,
'w'
)
as
f
:
...
...
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