mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-25639 "Convert to Jupyter Notebook" removed all line breaks in code.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import sys
|
||||
import nbformat
|
||||
from nbformat.v4 import new_code_cell, new_notebook
|
||||
|
||||
import codecs
|
||||
import nbformat
|
||||
import sys
|
||||
from nbformat.v4 import new_code_cell, new_notebook
|
||||
|
||||
name = sys.argv[-1][:-3]
|
||||
source = name + ".py"
|
||||
@@ -13,8 +12,8 @@ def parse_python(file):
|
||||
with open(file, "r") as file_descriptor:
|
||||
lines = []
|
||||
for line in file_descriptor:
|
||||
line = line.strip()
|
||||
if line.startswith('# In[') and line.endswith(']:') and lines:
|
||||
line_stripped = line.strip()
|
||||
if line_stripped.startswith('# In[') and line_stripped.endswith(']:') and lines:
|
||||
yield "".join(lines)
|
||||
lines = []
|
||||
continue
|
||||
@@ -22,6 +21,7 @@ def parse_python(file):
|
||||
if lines:
|
||||
yield "".join(lines)
|
||||
|
||||
|
||||
cells = []
|
||||
for cell_content in parse_python(source):
|
||||
cells.append(new_code_cell(source=cell_content))
|
||||
|
||||
Reference in New Issue
Block a user