FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Caffe_1.0_Windows/scripts/copy_notebook.py at master · Coderx7/Caffe_1.0_Windows · GitHub
Coderx7
/
Caffe_1.0_Windows
Public
Notifications
You must be signed in to change notification settings
Fork
8
Star
28
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Caffe_1.0_Windows
/
scripts
/
copy_notebook.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (28 loc) · 1.06 KB
Breadcrumbs
Caffe_1.0_Windows
/
scripts
/
copy_notebook.py
Copy path
File metadata and controls
32 lines (28 loc) · 1.06 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
#!/usr/bin/env python
"""
Takes as arguments:
1. the path to a JSON file (such as an IPython notebook).
2. the path to output file
If 'metadata' dict in the JSON file contains 'include_in_docs': true,
then copies the file to output file, appending the 'metadata' property
as YAML front-matter, adding the field 'category' with value 'notebook'.
"""
import
os
import
sys
import
json
filename
=
sys
.
argv
[
1
]
output_filename
=
sys
.
argv
[
2
]
content
=
json
.
load
(
open
(
filename
))
if
'include_in_docs'
in
content
[
'metadata'
]
and
content
[
'metadata'
][
'include_in_docs'
]:
yaml_frontmatter
=
[
'---'
]
for
key
,
val
in
content
[
'metadata'
].
iteritems
():
if
key
==
'example_name'
:
key
=
'title'
if
val
==
''
:
val
=
os
.
path
.
basename
(
filename
)
yaml_frontmatter
.
append
(
'{}: {}'
.
format
(
key
,
val
))
yaml_frontmatter
+=
[
'category: notebook'
]
yaml_frontmatter
+=
[
'original_path: '
+
filename
]
with
open
(
output_filename
,
'w'
)
as
fo
:
fo
.
write
(
'
\n
'
.
join
(
yaml_frontmatter
+
[
'---'
])
+
'
\n
'
)
fo
.
write
(
open
(
filename
).
read
())
Back
|
FazBrowse Home
|
New Git URL