Commit Graph

22 Commits

Author SHA1 Message Date
Berker Peksag cdea12b276 Make hy2py public. 2014-04-30 01:51:21 +03:00
Bob Tolbert bb567aab3e Enabling hy2py test on Windows 2014-03-14 10:21:07 -04:00
Nicolas Dandrimont 4022203496 Merge branch 'master' into pr/440 2014-01-17 20:20:39 +01:00
Gergely Nagy a619295dd7
bin/hy2py: Add a bunch of command-line options
The hy2py tool has been very useful for me, but most of the time, it's
only a part of its output that one is interested in. The whole output,
with source code, AST and python code together is one big monstrosity.
So instead of printing all that, lets have a few handy command-line
options to control which part gets printed.

By default, only the generated python source is, as that's what the name
of the tool implies.

Also, don't run it. That's what hy is for.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-01-14 09:17:56 +01: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 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
Morten Linderud c11b231c1c Merge pull request #328 from berkerpeksag/add-astor
Add astor to install_requires.
2013-12-11 08:13:03 -08:00
Berker Peksag e674eb4b56 Explicitly skip the skipped test in test_bin. 2013-12-10 19:43:56 +02:00
Berker Peksag 3e8941cdde Convert stdout and stderr to UTF-8 properly in the run_cmd helper. 2013-12-10 18:59:06 +02:00
Berker Peksag 870c136469 Add astor to install_requires.
`hy --spy` fails on hy 0.9.11.

    $ hy --spy
    hy 0.9.11
    => (type "hy")
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/hy/cmdline.py", line 68, in print_python_code
        import astor.codegen
    ImportError: No module named astor.codegen
2013-12-10 17:46:45 +02:00
Paul Tagliamonte c255607205 don't test the halting problem anymore. 2013-12-01 09:48:16 -05: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
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 59550c9abd tell flake8 to shut up 2013-06-25 19:23:44 -04:00
Morten Linderud 42468051f5 Builtins fix for 2 and 3, tests aswell 2013-06-25 17:02:02 +02:00
Nicolas Dandrimont 2b1b11a129 Fixup comment 2013-05-08 15:01:08 +02:00
Julien Danjou a823aca0c8 Run unit tests against hy2py
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-05-08 14:39:38 +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
Julien Danjou 3226ecc33f Fix bin/hy and add a unit test
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-20 22:28:45 +02:00