Skip to content

Commit

Permalink
fix path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hamelsmu committed Jan 30, 2020
1 parent fd5f5bd commit 1951765
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 124 deletions.
2 changes: 1 addition & 1 deletion nbdev/export2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def notebook2html(fname=None, force_all=False, n_workers=None, cls=HTMLExporter,
"Convert all notebooks matching `fname` to html files"
if fname is None:
files = [f for f in Config().nbs_path.glob('*.ipynb') if not f.name.startswith('_')]
else: files = glob.glob(fname)
else: files = list(p.parent.glob(p.name))
if len(files)==1:
force_all = True
if n_workers is None: n_workers=0
Expand Down
124 changes: 1 addition & 123 deletions nbs/03_export2html.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@
" \"Convert all notebooks matching `fname` to html files\"\n",
" if fname is None: \n",
" files = [f for f in Config().nbs_path.glob('*.ipynb') if not f.name.startswith('_')]\n",
" else: files = glob.glob(fname)\n",
" else: files = list(p.parent.glob(p.name))\n",
" if len(files)==1:\n",
" force_all = True\n",
" if n_workers is None: n_workers=0\n",
Expand Down Expand Up @@ -1364,128 +1364,6 @@
"#hide\n",
"notebook2script()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"files = [f for f in Config().nbs_path.glob('*.ipynb') if not f.name.startswith('_')]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[PosixPath('/home/jovyan/nbdev/nbs/99_search.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/06_cli.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/04_test.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/03_export2html.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/Issue_18.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/Untitled.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/01_sync.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/00_export.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/02_showdoc.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/07_clean.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/index.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/tutorial.ipynb'),\n",
" PosixPath('/home/jovyan/nbdev/nbs/05_merge.ipynb')]"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"files"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "NotImplementedError",
"evalue": "Non-relative patterns are unsupported",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNotImplementedError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-82-3d1ca43930fb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mPath\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'.'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mglob\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/home/jovyan/nbdev/nbs/*.ipynb'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/opt/conda/lib/python3.7/pathlib.py\u001b[0m in \u001b[0;36mglob\u001b[0;34m(self, pattern)\u001b[0m\n\u001b[1;32m 1098\u001b[0m \u001b[0mdrv\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mroot\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpattern_parts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_flavour\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparse_parts\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpattern\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1099\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdrv\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mroot\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1100\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mNotImplementedError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Non-relative patterns are unsupported\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1101\u001b[0m \u001b[0mselector\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_make_selector\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtuple\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpattern_parts\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1102\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mp\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mselector\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mselect_from\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNotImplementedError\u001b[0m: Non-relative patterns are unsupported"
]
}
],
"source": [
"\n",
"list(Path('.').glob('/home/jovyan/nbdev/nbs/*.ipynb'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"p = Path('../*.ipynb')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[PosixPath('../delete_this.ipynb')]"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(p.parent.glob(p.name))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"PosixPath('/home/jovyan/nbdev/nbs/../delete_this.ipynb')"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"_[0].absolute()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"_."
]
}
],
"metadata": {
Expand Down

3 comments on commit 1951765

@fabge
Copy link
Contributor

@fabge fabge commented on 1951765 Jan 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hamelsmu your recent commit created a new error. When the default Github Action tries to convert the notebook to html it throws following error:

Traceback (most recent call last):
  File "_action_files/nb2post.py", line 23, in <module>
    export2html.notebook2html(fname='_notebooks/*.ipynb', dest='_posts/')
  File "/home/runner/work/fabge.github.io/fabge.github.io/nbdev/nbdev/export2html.py", line 394, in notebook2html
    else: files = list(p.parent.glob(p.name))
NameError: name 'p' is not defined
##[error]Process completed with exit code 1.

@hamelsmu
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know 🤦‍♂ I opened #76 to fix

🙇

@fabge
Copy link
Contributor

@fabge fabge commented on 1951765 Jan 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, perfect! Thank you :)

Please # to comment.