Skip to content

Commit 5225498

Browse files
committed
func: convert ipynb to markdown
Signed-off-by: xiexianbin <me@xiexianbin.cn>
1 parent 74bd88a commit 5225498

13 files changed

Lines changed: 188 additions & 94 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,4 @@ cython_debug/
162162
# self define
163163
.DS_Store
164164
.history
165+
.vscode

ChangeLog

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
CHANGES
22
=======
33

4-
v0.1.0
5-
------
6-
7-
* feautre: base func, convert ipynb to hugo markdown files
8-
* init commit
4+
* init
5+
* Initial commit

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ FROM ubuntu:22.04
33
# Dockerfile build cache
44
ENV REFRESHED_AT 2023-05-07
55

6-
LABEL "com.github.actions.name"="nbcli"
7-
LABEL "com.github.actions.description"="nbcli"
6+
LABEL "com.github.actions.name"="nbctl"
7+
LABEL "com.github.actions.description"="nbctl"
88
LABEL "com.github.actions.icon"="chevrons-right"
99
LABEL "com.github.actions.color"="blue"
10-
LABEL "repository"="http://github.com/x-actions/python3-nbcli"
11-
LABEL "homepage"="http://github.com/x-actions/python3-nbcli"
10+
LABEL "repository"="http://github.com/x-actions/python3-nbctl"
11+
LABEL "homepage"="http://github.com/x-actions/python3-nbctl"
1212
LABEL "maintainer"="xiexianbin<me@xiexianbin.cn>"
1313

14-
LABEL "Name"="nbcli"
14+
LABEL "Name"="nbctl"
1515
LABEL "Version"="1.0.0"
1616

1717
ENV LC_ALL C.UTF-8
@@ -22,8 +22,8 @@ ENV LANGUAGE en_US.UTF-8
2222
RUN apt update && \
2323
apt install -y git python3 python3-pip skopeo jq && \
2424
cd ~ && \
25-
git clone https://github.com/x-actions/python3-nbcli.git && \
26-
cd python3-nbcli && \
25+
git clone https://github.com/x-actions/python3-nbctl.git && \
26+
cd python3-nbctl && \
2727
git checkout v1 && \
2828
pip3 install -r requirements.txt && \
2929
python3 setup.py --version && \

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
# python3-nbcli
1+
# python3-nbctl
22

33
将ipynb文件转化为hugo markdown文件/Convert ipynb to hugo markdown files
44

5-
[![PyPI-python3-nbcli](https://img.shields.io/pypi/v/python3-nbcli.svg?maxAge=3600)](https://pypi.org/project/python3-nbcli/)
5+
[![PyPI-python3-nbctl](https://img.shields.io/pypi/v/python3-nbctl.svg?maxAge=3600)](https://pypi.org/project/python3-nbctl/)
66

7-
Github Actions for [Container Images Sync](https://github.com/marketplace/actions/nbcli)
7+
Github Actions for [Container ipynb to markdown](https://github.com/marketplace/actions/nbctl)
88

99
## How to Use by Github Actions
1010

1111
```
12-
- name: convert ipynb to hugo markdown
13-
uses: x-actions/python3-nbcli@v1
12+
- name: install nbctl
13+
uses: x-actions/python3-nbctl@v1
14+
- name: convert ipynb to hugo markdown
15+
run: |
16+
find static/code/ai -type f -name "*.ipynb" | grep -v ".ipynb_checkpoints" | xargs -I{} nbctl --input {} -f
1417
```
1518

1619
## Dev and Test
@@ -23,8 +26,8 @@ pip3 install -r requirements.txt
2326
python3 setup.py install
2427
2528
# or
26-
pip3 install python3-nbcli
29+
pip3 install python3-nbctl
2730
2831
# run
29-
cisctl
32+
nbctl
3033
```

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'convert ipynb to hugo markdown'
2-
description: 'nbcli'
2+
description: 'nbctl'
33
author: 'xiexianbin <me@xiexianbin>'
44
inputs:
55
LOG_LEVEL:

entrypoint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ set -e
33

44
export LOG_LEVEL=${LOG_LEVEL:-"DEBUG"}
55

6+
echo $(pwd)
67
echo "## Check Package Version ##################"
78
bash --version
89
git version
9-
10-
nbcli

nbcli/shell.py

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
__all__ = ['__version__']
1818

1919

20-
version_info = pbr.version.VersionInfo('python3-nbcli')
20+
version_info = pbr.version.VersionInfo('python3-nbctl')
2121
# We have a circular import problem when we first run python setup.py sdist
2222
# It's harmless, so deflect it.
2323
try:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616

1717
CURRENT_PATH = os.getcwd()
1818
LOG_LEVEL = os.environ.get('LOG_LEVEL', 'DEBUG')
19+
DEFAULT_LOG_LEVEL = "INFO"

nbcli/logger.py renamed to nbctl/logger.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@
1919
from nbctl import constants
2020

2121

22-
def gen_logger():
22+
def gen_logger(level=constants.LOG_LEVEL):
2323
# create logger
24-
if constants.LOG_LEVEL == 'DEBUG':
24+
if level == 'DEBUG':
2525
log_level = logging.DEBUG
26-
elif constants.LOG_LEVEL == 'INFO':
26+
elif level == 'INFO':
2727
log_level = logging.INFO
28-
elif constants.LOG_LEVEL == 'WARN':
28+
elif level == 'WARN':
2929
log_level = logging.WARN
30-
elif constants.LOG_LEVEL == 'ERROR':
30+
elif level == 'ERROR':
3131
log_level = logging.ERROR
32-
elif constants.LOG_LEVEL == 'FATAL':
32+
elif level == 'FATAL':
3333
log_level = logging.FATAL
3434
else:
3535
log_level = logging.DEBUG
3636
formatter = logging.Formatter(
37-
fmt="%(asctime)-15s %(process)d %(levelname)s %(message)s - %(filename)s %(lineno)d",
37+
fmt="%(asctime)-15s %(process)d - %(filename)s:%(lineno)d %(levelname)s %(message)s",
3838
datefmt="%a %d %b %Y %H:%M:%S")
3939

40-
_logger = logging.getLogger(name="cis")
40+
_logger = logging.getLogger(name="nbctl")
4141
_logger.setLevel(log_level)
4242

43-
fh = logging.FileHandler(filename="cis.log")
44-
fh.setLevel(log_level)
45-
fh.setFormatter(formatter)
46-
_logger.addHandler(fh)
43+
# fh = logging.FileHandler(filename="nbctl.log")
44+
# fh.setLevel(log_level)
45+
# fh.setFormatter(formatter)
46+
# _logger.addHandler(fh)
4747

4848
oh = logging.StreamHandler(sys.stdout)
4949
oh.setLevel(log_level)
@@ -52,4 +52,4 @@ def gen_logger():
5252
return _logger
5353

5454

55-
logger = gen_logger()
55+
logger = gen_logger(constants.DEFAULT_LOG_LEVEL)

0 commit comments

Comments
 (0)