-
Notifications
You must be signed in to change notification settings - Fork 109
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
better deal from command line when file is not found #13
Comments
This should be quite simple, calling You can also use the |
@danilobellini We can give a try. I mean, I found two errors due to a file not found. @popmilo what do you think about this task? @danilobellini could also help you and discuss possible alternatives, however he is already engaged in another task. |
Yeah, I can do that. I'll start working on it. |
Finally managed to spend some more time reading main code, really well written and interesting. args = parser.parse_args(argv[1:])
if is_valid_file(parser, args.input):
args.func(args)
def is_valid_file(parser, arg):
if os.path.isfile(arg):
# File exists
return True
else:
parser.error('The file {} does not exist!'.format(arg))
return False This is the result of "pynes asm example.asm -o example.nes": Should there be a check for output file name validity also ? |
This can be slightly simpler, since the |
You are right :) if not os.path.isfile(args.input):
parser.error('The file {} does not exist!'.format(args.input)) |
@gutomaia Should I make a pull request for just this one small commit, or work on something else ? |
@popmilo I've just take a look on that, it look's nice. However I, to help improve the community and the software also, the best approach to solve a request is to write a test. What you have done so far is great. Problem is, if someone like me, break your code. No one will notice 'cause there is tests related to that part. On the project there is a commandline_test.py, first take a look on it. Try to figure out what test would break the application. If you need any help, just ask! I'm just trying to lead you into a path, not just give you the answer! Good luck! |
At the command line when calls: "pynes asm example.asm -o example.nes", you receive an ugly stack trace on the file doesn't exists. User must receive a better error handle in that case.
The text was updated successfully, but these errors were encountered: