FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mpl-probscale/docs/tutorial/make.py at master · matplotlib/mpl-probscale · GitHub
matplotlib
/
mpl-probscale
Public
Notifications
You must be signed in to change notification settings
Fork
11
Star
40
Code
Issues
7
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
mpl-probscale
/
docs
/
tutorial
/
make.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
34 lines (24 loc) · 1.01 KB
Breadcrumbs
mpl-probscale
/
docs
/
tutorial
/
make.py
Copy path
File metadata and controls
34 lines (24 loc) · 1.01 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
import
os
import
glob
import
nbformat
from
nbconvert
import
RSTExporter
from
nbconvert
.
preprocessors
import
ExecutePreprocessor
def
convert
(
nbfile
):
basename
,
_
=
os
.
path
.
splitext
(
nbfile
)
meta
=
{
"metadata"
: {
"path"
:
"."
}}
with
open
(
nbfile
,
"r"
,
encoding
=
"utf-8"
)
as
nbf
:
nbdata
=
nbformat
.
read
(
nbf
,
as_version
=
4
,
encoding
=
"utf-8"
)
runner
=
ExecutePreprocessor
(
timeout
=
600
,
kernel_name
=
"probscale"
)
runner
.
preprocess
(
nbdata
,
meta
)
img_folder
=
basename
+
"_files"
body_raw
,
images
=
RSTExporter
().
from_notebook_node
(
nbdata
)
body_final
=
body_raw
.
replace
(
".. image:: "
,
".. image:: {}/"
.
format
(
img_folder
))
with
open
(
basename
+
".rst"
,
"w"
,
encoding
=
"utf-8"
)
as
rst_out
:
rst_out
.
write
(
body_final
)
for
img_name
,
img_data
in
images
[
"outputs"
].
items
():
img_path
=
os
.
path
.
join
(
img_folder
,
img_name
)
with
open
(
img_path
,
"wb"
)
as
img
:
img
.
write
(
img_data
)
if
__name__
==
"__main__"
:
for
nbfile
in
glob
.
glob
(
"*.ipynb"
):
convert
(
nbfile
)
Back
|
FazBrowse Home
|
New Git URL