fitzgen/pycco — Issue #51: Inaccurate parsing of relative paths on files with no extensions
Author: xiongchiamiov
Created: 2012-02-21 23:37:00+00:00
State: open

[$]> pycco ../lastfm-tail/bin/lastfm-tail
Traceback (most recent call last):
File "/Users/pearson/Documents/docdrop/env/bin/pycco", line 8, in
load_entry_point('Pycco==0.3.0', 'console_scripts', 'pycco')()
File "/Users/pearson/Documents/docdrop/env/lib/python2.6/site-packages/pycco/main.py", line 480, in main
process(sources, outdir=opts.outdir, preserve_paths=opts.paths)
File "/Users/pearson/Documents/docdrop/env/lib/python2.6/site-packages/pycco/main.py", line 417, in process
next_file()
File "/Users/pearson/Documents/docdrop/env/lib/python2.6/site-packages/pycco/main.py", line 411, in next_file
f.write(generate_documentation(s, preserve_paths=preserve_paths, outdir=outdir))
File "/Users/pearson/Documents/docdrop/env/lib/python2.6/site-packages/pycco/main.py", line 46, in generate_documentation
sections = parse(source, fh.read())
File "/Users/pearson/Documents/docdrop/env/lib/python2.6/site-packages/pycco/main.py", line 66, in parse
language = get_language(source)
File "/Users/pearson/Documents/docdrop/env/lib/python2.6/site-packages/pycco/main.py", line 324, in get_language
return languages[ source[source.rindex("."):] ]
KeyError: './lastfm-tail/bin/lastfm-tail'

The problem is with `source.rindex(".")` - when a file doesn't have an extension, this splits on the `..` part of the relative path.