Commit Graph

28 Commits

Author SHA1 Message Date
Berker Peksag cdea12b276 Make hy2py public. 2014-04-30 01:51:21 +03:00
Gergely Nagy 5b78735011 hy/cmdline.py: Add support for running with --spy -i
There's no reason why one would need to choose between --spy and -i, so
pass down options.spy to run_icommand, and then to HyREPL, so we can
have both.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
2014-01-13 22:12:32 +01:00
Bob Tolbert 05899423df Changing --show_tracebacks to --show-tracebacks 2013-12-31 09:56:03 -07:00
Bob Tolbert 765dba3e56 More updates, including from Foxboron, for errors like (for) 2013-12-31 09:56:03 -07:00
Bob Tolbert f6160c755a Much better version of new error messages.
This version is much simpler.

At the point that the exception is raised, we don't have access to
the actual source, just the current expression. but as the
exception percolates up, we can intercept it, add the source and
the re-raise it.

Then at the final point, in the cmdline handler, we can choose to
let the entire traceback print, or just the simpler, direct error
message.

And even with the full traceback, the last bit is nicely formatted
just like the shorter, simpler message.

The error message is colored if clint is installed, but to avoid
yet another dependency, you get monochrome without clint.

I'm sure there is a better way to do the markup, the current method
is kludgy but works.

I wish there was more shared code between HyTypeError and LexException
but they are kind of different in some fundamental ways.

This doesn't work (yet) with runtime errors generated from Python,
like NameError, but I have a method that can catch NameError and turn it
into a more pleasing output.

Finally, there is no obvious way to raise HyTypeError from pure Hy code,
so methods in core/language.hy throw ugly TypeError/ValueError.
2013-12-31 09:56:03 -07:00
Kenan Bölükbaşı 3f590f8916 Reflect parameters of code.InteractiveConsele in HyREPL in order to make hy run inside Blender. 2013-12-29 01:22:16 +02:00
Henrique Carvalho Alves 62bc86a0b5 Fix sys.argv to reflect default Python behaviour
By default, calling the Python REPL without arguments causes
sys.argv to be a non-empty list with an empty string, and some
modules (e.g., pyNN) rely on that.
2013-11-29 23:51:41 -02:00
Berker Peksag f21ddeeded Add hy._compat module.
There was a couple of duplicate imports and type checkings in the
codebase. So I added a new module to unify all Python 2 and 3
compatibility codes.

Also, this is a somewhat common pattern in Python. See Jinja2 for
example:

https://github.com/mitsuhiko/jinja2/blob/master/jinja2/_compat.py
2013-09-29 12:10:08 +03:00
Bob Tolbert e33c27d447 Fixing blank line Flake8 failures 2013-08-24 08:33:13 -06:00
Konrad Hinsen a3847191b6 Merge branch 'master' into spy-mode 2013-08-20 10:12:23 +02:00
Julien Danjou e158fba865 Merge pull request #265 from rwtolbert/hyc_args_fix
Add CL handling to hyc
2013-08-20 01:10:44 -07:00
Konrad Hinsen 3321daa4cf Add "spy mode" to REPL
With the command-line option --spy, the Hy REPL prints the Python
equivalent of each expression before evaluating it.
2013-08-19 15:27:55 +02:00
Nicolas Dandrimont 81af09d002 Wire the rply parser
Amend the tests to account for the changes
2013-07-28 17:36:36 +02:00
Bob Tolbert d960dc963f Add CL handling to hyc
This adds real command line handling to 'hyc' for issue #256

This fix catches missing/unreadable files and prints a nice
error message instead of a nasty stack trace when trying to
compile a non-existent file.

Also add this non-existent file check to hy to prevent the
current stack trace from something like "hy foobarbaz" when
"foobarbaz" doesn't exist.

also changes the failure return value to 2 to match Python.
2013-07-26 08:40:56 -06:00
Bob Tolbert df7bb1d29a Provide bin scripts for both Windows and *nix
Summary: This update does away with the scripts in bin and changes
setup.py to use entry_points in cmdline.py for the scripts 'hy' and
'hyc'.

This fixes installing and running on Windows.

The tests are updated to run the 'hy' script produced by setup.py
and not from bin/hy. This is more correct and makes the tox tests
run on both Window and *nix.

For running hy or nosetests directly in the source tree, you do have
to run 'python setup.py develop' first. But since tox runs and builds
dists, all tox tests pass on all platforms.

Also, since there is no built-in readline on Windows, the setup.py
only on Windows requires 'pyreadline' as a replacement.

Switched from optparse to argparse in cmdline.py

Instead of trying to manually separate args meant for
hy from args meant for a hy script, this switches from
optparse to argparse for the CLI.

argparse automatically peels out args meant for hy and leaves
the rest, including the user hy script in options.args.

This fixes the issue @paultag found running "hy foo" where
foo is not a real file. Also added a test that makes sure
trying to run a non-existent script exits instead of dropping
the user into the REPL.

Added argparse as setup.py resource (and removed from tox.ini) as well as removed uses of deprecated setf
2013-07-14 09:06:42 -06:00
Paul Tagliamonte b78be9a594 Jank @olasd's hack, clean up core.
The core shall from now on be only for the core language bits. Macro
 bits shall live in hy.macros and in hy.compiler. This cleans up
 garbage.
2013-07-06 14:00:11 -04:00
Paul Tagliamonte 2c4c95725e Style fixes. 2013-07-06 13:43:05 -04:00
Ralph Moritz 748f54b2f9 Move code from hy.readline_helpers into new hy.completer.completion context
manager so we can "wrap" readline completion around REPL interaction.
2013-07-06 18:02:01 +02:00
Paul Tagliamonte 56ccdf97e3 Style fixes. 2013-07-04 21:31:17 -04:00
Ralph Moritz 888dc19882 Get Hy working on Windows by making readline use conditional. 2013-07-01 22:41:56 +02:00
Morten Linderud 42468051f5 Builtins fix for 2 and 3, tests aswell 2013-06-25 17:02:02 +02:00
Konrad Hinsen 269da19d76 Make macros module-specific.
A macro is available in the module where it was defined and
in any module that does a require of the defining module.
Only macros defined in hy.core are globally available.
Fixes #181
2013-05-16 15:34:14 +02:00
Nicolas Dandrimont 0986f9001e Change macros to be called with separate arguments
This provides free argument-length checking for macros.
2013-05-11 09:09:34 +02:00
Will Kahn-Greene 07dec18dc3 Fix "hy -c CMD" to show lex errors; add tests
* tells you there's a lex error, but doesn't tell you much else
* adds tests for all new bin/hy functionality
2013-04-24 22:23:12 -04:00
Will Kahn-Greene 08b30e8195 Back-figuring the license/copyright info
I did a git log thing to figure out who touched bin/hy and copied
those people over here since the bulk of the code came from bin/hy.
2013-04-24 09:03:56 -04:00
Will Kahn-Greene 3f7f241097 Fix license header 2013-04-24 08:57:51 -04:00
Will Kahn-Greene fb8140b6bc Add license to new file 2013-04-24 08:32:03 -04:00
Will Kahn-Greene 4e59af0033 Redid command line code
This supports:

* -h, --help
* --version
* -c cmd
* -i cmd
* file
* -

Plus it's easy to add new options.

Also, now we can do ridiculous things like have projects where
the installation is:

$ curl -s http://example.com/install-hypster-program | hy
2013-04-23 22:02:41 -04:00