FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-mode/website/PMGenerator.py at master · wujiang/python-mode · GitHub
wujiang
/
python-mode
Public
forked from
russell/python-mode
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-mode
/
website
/
PMGenerator.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
72 lines (60 loc) · 2.13 KB
Breadcrumbs
python-mode
/
website
/
PMGenerator.py
Copy path
File metadata and controls
72 lines (60 loc) · 2.13 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""Standard Generator with slight tweaks."""
from
StandardGenerator
import
StandardGenerator
try
:
import
rst_html
except
ImportError
:
print
'Unable to import rst_html/docutils'
print
'Get and install the docutils from docutils.sf.net'
rst_html
=
None
class
PMGenerator
(
StandardGenerator
):
def
__init__
(
self
,
file
,
rootdir
,
relthis
):
StandardGenerator
.
__init__
(
self
,
file
,
rootdir
,
relthis
)
self
.
rootdir
=
rootdir
self
.
filename
=
file
self
.
__body
=
None
self
.
__cont
=
None
def
get_corner
(
self
):
return
(
'''<center><a href="%(rootdir)s/">No Logo!</a></center>'''
%
self
.
__dict__
)
def
get_banner
(
self
):
return
'''
\
<table width="100%%">
<tr>
<td><a href="%(rootdir)s/docs/">Python-Mode Documentation</a></td>
<td><a href="http://www.python.org/">Python</a></td>
</tr>
<tr>
<td><a href="http://www.gnu.org/software/emacs/">GNU Emacs</a></td>
<td><a href="http://www.xemacs.org/">XEmacs</a></td>
</tr>
</table>
'''
%
self
.
__dict__
def
_grokbody
(
self
):
if
self
.
__body
is
None
:
data
=
self
.
_parser
.
fp
.
read
()
# convert to Unicode:
text
=
data
.
decode
(
self
.
get_encoding
())
if
self
.
get_content_type
()
==
'text/x-rst'
:
if
rst_html
is
None
:
print
'ReST-to-HTML conversion not available'
else
:
text
=
rst_html
.
process_rst
(
self
.
filename
,
text
)
# convert Unicode back to 8-bit string:
text
=
text
.
encode
(
self
.
get_charset
(),
'xmlcharrefreplace'
)
i
=
text
.
find
(
'<!--table-stop-->'
)
if
i
>=
0
:
self
.
__body
=
text
[:
i
]
self
.
__cont
=
text
[
i
+
17
:]
else
:
# there is no wide body
self
.
__body
=
text
def
get_body
(
self
):
self
.
_grokbody
()
return
self
.
__body
def
get_cont
(
self
):
self
.
_grokbody
()
return
self
.
__cont
def
get_encoding
(
self
):
return
self
.
_parser
.
get
(
'encoding'
,
'utf-8'
)
def
get_content_type
(
self
):
return
self
.
_parser
.
get
(
'content-type'
,
use_defaults
=
False
)
Back
|
FazBrowse Home
|
New Git URL