ipython/nbconvert — pull request #41 by ivanov (2012-10-27 20:56:12+00:00)
Title: 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
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 ['', '

'] + 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'
```