nemonik/Intellect — pull request #3 by Locker537 (2012-07-31 21:32:13+00:00)
Title: Raise exceptions when evaluating paths to files as actual rules

Intellect would print errors captured from antlr on stderr to stdout. Specifically, if you tried to learn a file that did not exist, you would get an antlr error printed to stdout. The specific error was in the form of "line 1:0 no viable alternative at input u'/'"

Intellect now will raise a generic exception if it cannot learn a string when treated as a path to a file, or as actual rules. It may be appropriate to write custom exception classes to handle these types of errors. Personally, I think this type of error should raise an exception as it's generally catastrophic to the application using Intellect.

You can exercise the issue and fix, by using the following simple code:
https://gist.github.com/3220727

While I should have broken it into multiple commits and pull requests, I also fixed a few string comparisons.
```
if x != "":
```
Is cleaner as:
```
if x:
```

I also removed the filepath regex, and replaced it with a call to "isfile" and an attempt to read the file.