Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Auto Research Note
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSNS lab
Auto Research Note
Commits
75422fc0
Commit
75422fc0
authored
3 years ago
by
jhjung
Browse files
Options
Downloads
Patches
Plain Diff
v0.1.7
parent
04eaf53c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nbresnote.py
+15
-8
15 additions, 8 deletions
nbresnote.py
with
15 additions
and
8 deletions
nbresnote.py
+
15
−
8
View file @
75422fc0
import
json
,
base64
,
os
,
pickle
,
datetime
,
string
,
re
import
json
,
base64
,
os
,
pickle
,
datetime
,
string
,
re
__version__
=
"
0.1.
4
"
__version__
=
"
0.1.
7
"
### from ipynb extract markdown and noted output for document organization
### from ipynb extract markdown and noted output for document organization
class
nbparser
:
class
nbparser
:
...
@@ -16,7 +16,7 @@ class nbparser:
...
@@ -16,7 +16,7 @@ class nbparser:
self
.
notebook
=
json
.
loads
(
"
\n
"
.
join
(
open
(
path
).
readlines
()))
self
.
notebook
=
json
.
loads
(
"
\n
"
.
join
(
open
(
path
).
readlines
()))
self
.
outroot
=
os
.
path
.
join
(
output_root
,
"
source
"
)
self
.
outroot
=
os
.
path
.
join
(
output_root
,
"
source
"
)
self
.
opath
=
os
.
path
.
join
(
self
.
outroot
,
self
.
folder
,
self
.
basename
)
self
.
opath
=
os
.
path
.
join
(
self
.
outroot
,
self
.
folder
,
self
.
basename
)
os
.
makedirs
(
self
.
opath
,
exist_ok
=
True
)
self
.
TOC
,
self
.
source
=
[],[]
self
.
TOC
,
self
.
source
=
[],[]
self
.
fig
,
self
.
code
=
[],
[]
self
.
fig
,
self
.
code
=
[],
[]
self
.
table
=
[]
self
.
table
=
[]
...
@@ -109,6 +109,7 @@ class nbparser:
...
@@ -109,6 +109,7 @@ class nbparser:
self
.
save_fig
(
self
.
outputpath
(
fname
),
data
[
'
data
'
][
key
])
self
.
save_fig
(
self
.
outputpath
(
fname
),
data
[
'
data
'
][
key
])
def
save_fig
(
self
,
fname
,
base64fig
):
def
save_fig
(
self
,
fname
,
base64fig
):
os
.
makedirs
(
self
.
opath
,
exist_ok
=
True
)
with
open
(
fname
,
"
wb
"
)
as
f
:
with
open
(
fname
,
"
wb
"
)
as
f
:
f
.
write
(
base64
.
b64decode
(
base64fig
))
f
.
write
(
base64
.
b64decode
(
base64fig
))
...
@@ -196,7 +197,7 @@ class nbparser:
...
@@ -196,7 +197,7 @@ class nbparser:
return
s
return
s
def
source_convert
(
self
):
def
source_convert
(
self
):
source
=
[
line
if
not
line
==
"
!TOC
"
else
self
.
toc_source
()
for
line
in
self
.
source
]
# Table of Contents
source
=
[
line
if
not
line
==
"
!TOC
"
else
self
.
toc_source
()
for
line
in
self
.
source
if
line
]
# Table of Contents
source
=
"
\n\n
"
.
join
(
source
)
source
=
"
\n\n
"
.
join
(
source
)
# double bracket to ref
# double bracket to ref
...
@@ -217,10 +218,10 @@ class nbparser:
...
@@ -217,10 +218,10 @@ class nbparser:
def
write_markdown
(
self
):
def
write_markdown
(
self
):
source
=
self
.
source_convert
()
source
=
self
.
source_convert
()
if
source
:
### Write markdown
### Write markdown
with
open
(
self
.
fname
,
"
w
"
)
as
f
:
with
open
(
self
.
fname
,
"
w
"
)
as
f
:
f
.
write
(
source
)
f
.
write
(
source
)
def
toc_source
(
TOC
):
def
toc_source
(
TOC
):
...
@@ -243,7 +244,8 @@ def daily_note(note_path, check):
...
@@ -243,7 +244,8 @@ def daily_note(note_path, check):
source
=
pickle
.
load
(
f
)
source
=
pickle
.
load
(
f
)
mod
,
record
=
modified_check
(
source
,
check
)
mod
,
record
=
modified_check
(
source
,
check
)
write_daily
(
note_path
,
mod
,
record
)
if
mod
:
write_daily
(
note_path
,
mod
,
record
)
def
modified_check
(
source
,
check
):
def
modified_check
(
source
,
check
):
mod
=
{}
mod
=
{}
...
@@ -299,7 +301,12 @@ rm __tmp__files
...
@@ -299,7 +301,12 @@ rm __tmp__files
cd wiki
cd wiki
git add *
git add *
if [ `git diff --cached --name-only| wc -l` -eq 0 ]
then
echo
"
nothing to commit
"
else
git commit -m
"
Auto commit from nbresnote `date +%F`
"
git commit -m
"
Auto commit from nbresnote `date +%F`
"
fi
"""
"""
pushsource
=
"""
#!/bin/bash
pushsource
=
"""
#!/bin/bash
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment