improve config line magic #3116

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@Carreau
Member
Carreau commented Mar 30, 2013

check for MissUpperCasing and add additional info
if there is a case insensitive match on clas

if line of the form

%config Class.value

return the value of the trait instead of just throwing bad usage


Yes the code is ugly, I'll reread it when I'll be backs.

@ellisonbg ellisonbg commented on an outdated diff Apr 13, 2013
IPython/core/magics/config.py
elif '=' not in line:
- raise UsageError("Invalid config statement: %r, "
- "should be Class.trait = value" % line)
+ extra = ''
+ lcname = map(str.lower,classnames)
+ ll = line.lower()
+ if ll in lcname:
+ correctname = classnames[lcname.index(ll) ]
+ extra = '\nDid you mean '+correctname
+ msg = "Invalid config statement: %r, "
@ellisonbg
ellisonbg Apr 13, 2013 Member

The way the error message is split on multiple lines doesn't quite look right. Maybe try to clean this up.

@ellisonbg
Member

This code works as advertised. I would like to see the error message formatted a little more nicely and you said you wanted to look at the code one more time.

@Carreau Carreau improve config line magic
check for MissUpperCasing and add additional info
if there is a case insensitive match on clas

if line of the form

%config Class.value

return the value of the trait instead of just throwing bad usage
8ae53f3
@Carreau
Member
Carreau commented Apr 13, 2013

Slightly change the message. I'm still not found of the regular expression to detect what the user want to do, but I guess it is enough for current case.

In [1]: %config zmqinteractiveshell
UsageError: Invalid config statement: u'zmqinteractiveshell', should be `Class.trait = value`.
Did you mean ZMQInteractiveShell (Difference in Case)

In [2]: %config foobar
UsageError: Invalid config statement: u'foobar', should be `Class.trait = value`.
@minrk minrk commented on the diff Apr 16, 2013
IPython/core/magics/config.py
elif '=' not in line:
- raise UsageError("Invalid config statement: %r, "
- "should be Class.trait = value" % line)
+ extra = ''
+ lcname = map(str.lower,classnames)
+ ll = line.lower()
+ if ll in lcname:
+ correctname = classnames[lcname.index(ll) ]
+ extra = '\nDid you mean '+correctname+' (Difference in Case)'
@minrk
minrk Apr 16, 2013 Member

make this '\nDid you mean ' + correctname + ' (different case)?'

@minrk
Member
minrk commented Apr 16, 2013

tiny grammar fix, then it's ready to go.

@Carreau
Member
Carreau commented Apr 16, 2013

Preparing to go to Japan for 2 weeks in a few hours. will probably not
reconnect before next month.

Le mardi 16 avril 2013, Min RK a écrit :

tiny grammar fix, then it's ready to go.


Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/pull/3116#issuecomment-16459702
.

@minrk
Member
minrk commented Apr 16, 2013

No problem, I'll do the little tweak locally, and merge. Thanks!

@minrk minrk added a commit to minrk/ipython that referenced this pull request Apr 17, 2013
@minrk minrk finish up PR #3116
Matthias is on vacation, but there was one last tweak left.

closes #3116
287a7a1
@minrk minrk referenced this pull request Apr 17, 2013
Merged

finish up PR #3116 #3194

@minrk minrk added a commit that closed this pull request Apr 17, 2013
@minrk minrk finish up PR #3116
Matthias is on vacation, but there was one last tweak left.

closes #3116
287a7a1
@minrk minrk closed this in 287a7a1 Apr 17, 2013
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
@minrk minrk finish up PR #3116
Matthias is on vacation, but there was one last tweak left.

closes #3116
db92dbd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment