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

Adding .get methods #205

Merged
merged 11 commits into from
Jul 23, 2015
Merged

Adding .get methods #205

merged 11 commits into from
Jul 23, 2015

Conversation

henryiii
Copy link
Collaborator

This was originally going to be a fix for #193, but it turned out that it was already fixed in 1.5.0. However, this is still a more intuitive and useful way to try multiple commands, imo.

Given the method of #193, you currently can do

gzip_cmd = getattr(pb.cmd, 'pigz', pb.cmd.gzip)

Now you can do

gzip_cmd = local.get('pigz', 'gzip')

This is reminiscent of the .get function on dicts. This also can be used to search common locations for commands, for example,

pandoc = local.get('pandoc',
                   '~/AppData/Local/Pandoc/pandoc.exe',
                   '/Program Files/Pandoc/pandoc.exe',
                   '/Program Files (x86)/Pandoc/pandoc.exe')

since it returns CommandNotFound if the path is invalid.

tomerfiliba added a commit that referenced this pull request Jul 23, 2015
@tomerfiliba tomerfiliba merged commit 7c228b2 into tomerfiliba:master Jul 23, 2015
@henryiii henryiii modified the milestone: v1.5.1 Aug 27, 2015
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