Make the default stringifier a setting #9

Merged
merged 6 commits into from Jul 29, 2011

Projects

None yet

2 participants

@asmeurer
Collaborator

Right now, only type, str, and repr are allowed, but the ability to
define your own stringifier will be added.

With the code cleanups we've done, adding new options is really easy.

I still want to add the ability to define your own custom stringifier (I think I will just require the user to define it in a file), but I am too tired to do any more work today. You can merge this if you want, or wait for the rest of the fixes.

asmeurer added some commits Jul 28, 2011
@asmeurer asmeurer Make the default stringifier a setting
Right now, only type, str, and repr are allowed, but the ability to
define your own stringifier will be added.
90d21d3
@asmeurer asmeurer Don't try to update a custom theme automatically in the prefs window
This doesn't work, as the user will likely try to choose "Custom" before
entering a file name, resulting in an error.  So instead, make choosing
"Custom" select the file entry box, and don't try to load it until the
preferences dialog is closed.  Built-in themes are still updated
automatically.
654504a
@asmeurer asmeurer Add support for custom stringifiers to PuDB
Also included in this commit is a change that makes the custom theme and
custom stringifier preferences persistant, so that the user does not
have to re-enter them if deselects "Custom".  This wasn't easy to split
out, so it's included here.

I still need to add support for manually choosing a the custom
stringifier on a per-variable basis.
820be5f
@asmeurer asmeurer Add example-stringifier.py file
This shows one possible use of the custom stringifier functionality.
The example function computes str(), unless it takes longer than one
second to compute (it uses signal.alarm() to determine this), in which
case it falls back to type.
9f8cb66
@asmeurer asmeurer Add some more useful information to the example-stringifier.py file acacfaa
@asmeurer asmeurer Add support for custom stringifiers on a per-variable basis
The keyboard shortcut for custom stringifiers is c.
4d287ba
@asmeurer
Collaborator

OK, this is ready to be reviewed. I've added full support for custom stringifiers. You just give the path to a file that contains a function pudb_stringifier at the module level, and it will use that. I included an example-stringifier.py to show one potential example (the one from the mailing list).

I also made some improvements to the custom stuff for both stringifiers and themes (see the commit messages). For example, choosing "custom" now selects the text entry field, and the stuff is not auto-updated (since the user will likely not have entered the file path yet). Also, the paths are now persistant, even if the user chooses a non-custom option. This is particularly useful for custom stringifiers, as you can manually change the stringifier for each variable, which means that you can use the custom one even if it isn't selected as the default.

@inducer inducer merged commit 4018c98 into inducer:master Jul 29, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment