Commit 2af1087
committed
robust css/preamble path finding despite symlinks
I have a `~/bin/nbconvert` symlink to ~/code/nbconvert/nbconvert.py so
that I can call it from anywhere in the filesystem. Stylesheets were
found previously using `__file__`, which can change depending on where
one puts symlinks.
Additionally, I found one other place where such a situation was
anticipated, but the solution was using a bit too much code. The
simplest way to get around this situation is to used `os.path.realpath`,
which is what I've done here.
Here's a traceback of the error, in case someone stumbles into this.
$ nbconvert -f html test_display.ipynb
Traceback (most recent call last):
File "/home/pi/bin/nbconvert", line 1490, in <module>
main(infile=args.infile[0], format=args.format)
File "/home/pi/bin/nbconvert", line 1459, in main
htmlfname = converter.render()
File "/home/pi/bin/nbconvert", line 311, in render
self.output = self.convert()
File "/home/pi/bin/nbconvert", line 293, in convert
lines.extend(self.optional_header())
File "/home/pi/bin/nbconvert", line 808, in optional_header
return ['<html>', '<head>'] + self.header_body() + \
File "/home/pi/bin/nbconvert", line 790, in header_body
header.extend(self._stylesheet(sheet))
File "/home/pi/bin/nbconvert", line 756, in _stylesheet
with io.open(fname, encoding='utf-8') as f:
IOError: [Errno 2] No such file or directory: '/home/pi/bin/css/static_html.css'1 parent 39aa8a9 commit 2af1087
1 file changed
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | | - | |
| 777 | + | |
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
1017 | | - | |
1018 | | - | |
| 1017 | + | |
1019 | 1018 | | |
1020 | 1019 | | |
1021 | 1020 | | |
| |||
0 commit comments