landscapeio/prospector — pull request #71 by jquast (2014-11-20 04:24:22+00:00)
Title: Detect target file encoding in autodetect.py

Closes issue #65. Infer the target python source file encoding before attempting to parse it for imports of interest (such as django).

- First, using byte order markers (BOM). An example of
this was found in ``setuptools/tests/script-with-bom.py``.
- Secondly, using PEP263 regular expression over the first
two lines -- only if they begin with a comment (#), decoded
as utf8, to determine if it has a source file encoding,
by seeking statements such as ``# coding: latin1``.
- Finally, default to utf8. If the target file fails to decode,
or the given codec is not found -- issue a warning and move
on to the next file.