Added command line tool with basic options for parsing torrents#10
Open
ferret-guy wants to merge 2 commits into
Open
Added command line tool with basic options for parsing torrents#10ferret-guy wants to merge 2 commits into
ferret-guy wants to merge 2 commits into
Conversation
roidayan
reviewed
Jul 8, 2017
| @@ -0,0 +1,33 @@ | |||
| import argparse | |||
Contributor
There was a problem hiding this comment.
First line for script should be the shebang line.
I.e. #!/usr/bin/python
Then the script can be executable.
| import PTN | ||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser(description='Description of your program') |
Contributor
There was a problem hiding this comment.
This is a redundant description
| parser.add_argument('-j','--json', dest="json", action='store_true', default=False, help='Output in json format') | ||
| parser.add_argument('-y','--yaml', dest="yaml", action='store_true', default=False, help='Output to YAML') | ||
| parser.add_argument('-f','--file', dest="filename", default=False, help='Output to file as well as command line') | ||
| args = vars(parser.parse_args()) |
Contributor
There was a problem hiding this comment.
Why you use vars()? Use args.yaml or args.json to get user input
| exit(1) | ||
| elif args['json']: | ||
| try: | ||
| try: import simplejson as json |
Contributor
There was a problem hiding this comment.
For consistency with the rest of the code should be in a new line.
Author
|
@roidayan Went ahead and addressed your comments, please take a look again |
Author
|
@divijbindlish can you take a look at this for merging? |
roidayan
reviewed
Jul 8, 2017
| except ImportError, e: | ||
| except ImportError: | ||
| print "yaml module required for yaml output!\nInstall with 'pip install ruamel.yaml'" | ||
| exit(1) |
Contributor
There was a problem hiding this comment.
you should use sys.exit() instead of exit().
roidayan
reviewed
Aug 11, 2017
| output = json.dumps(info, indent=4, sort_keys=True) | ||
| except ImportError: | ||
| print "json module required for json output!\nInstall with 'pip install simplejson' or update python to 2.6+" | ||
| exit(1) |
| output = str(yaml.dump(info, default_flow_style=False)) | ||
| except ImportError: | ||
| print "yaml module required for yaml output!\nInstall with 'pip install ruamel.yaml'" | ||
| exit(1) |
| from ruamel import yaml | ||
| output = str(yaml.dump(info, default_flow_style=False)) | ||
| except ImportError: | ||
| print "yaml module required for yaml output!\nInstall with 'pip install ruamel.yaml'" |
Contributor
There was a problem hiding this comment.
print statement is not compatible with python3 use print() function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Responding to #2
creates command link hook called parse-torrent-name
example: