Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show: raise ValueError if a filename isn't given to 'show' command #7

Merged
merged 1 commit into from
Sep 18, 2015
Merged

show: raise ValueError if a filename isn't given to 'show' command #7

merged 1 commit into from
Sep 18, 2015

Conversation

phrohdoh
Copy link
Contributor

@phrohdoh phrohdoh commented Aug 8, 2015

Turns

genie> help

Documented commands (type help <topic>):
========================================
drs     help  palette  player  saveall    show
export  ls    play     save    savefirst  showanim

genie> show
Now showing ''. Keys:
        q       return to prompt
        +/-     zoom
        a       show the frame hotspot
        arrow keys      to cycle between frames

Traceback (most recent call last):
  File "browse_slp.py", line 307, in do_show
    self.loader.show_filename(name)
  File "browse_slp.py", line 55, in show_filename
    resource_id = _get_resource_id(filename)
  File "browse_slp.py", line 20, in _get_resource_id
    return int(filename.split('.')[0])
ValueError: invalid literal for int() with base 10: ''

genie>

into

genie> help

Documented commands (type help <topic>):
========================================
drs     help  palette  player  saveall    show
export  ls    play     save    savefirst  showanim

genie> show
Now showing ''. Keys:
        q       return to prompt
        +/-     zoom
        a       show the frame hotspot
        arrow keys      to cycle between frames

Traceback (most recent call last):
  File "browse_slp.py", line 313, in do_show
    self.loader.show_filename(name)
  File "browse_slp.py", line 60, in show_filename
    raise ValueError("no filename given")
ValueError: no filename given

genie>

If you instead want me to raise elsewhere (such as do_show) I can do that.
Or we could give the user a message back indicating incorrect usage.

Just let me know.

@phrohdoh phrohdoh changed the title show: raise ValueError is a filename isn't given to 'show' command show: raise ValueError if a filename isn't given to 'show' command Aug 8, 2015
@fredreichbier
Copy link
Owner

I think this is a good thing (I didn't really think about usability at all)! But I'd in fact rather like the exception to be raised directly in do_show. What do you think?

@phrohdoh
Copy link
Contributor Author

Works for me.
I'll give this an update.

@phrohdoh
Copy link
Contributor Author

@fredreichbier updated as requested.
Also handles invalid filenames now (such as -1.slp).

fredreichbier added a commit that referenced this pull request Sep 18, 2015
show: raise ValueError if a filename isn't given to 'show' command
@fredreichbier fredreichbier merged commit 4c59369 into fredreichbier:master Sep 18, 2015
@fredreichbier
Copy link
Owner

Sorry for the delay, and thanks for the patch!

@phrohdoh phrohdoh deleted the drs-show-value-error branch September 18, 2015 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants