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

Completion support, OPML import/export #67

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

FilipBB
Copy link
Contributor

@FilipBB FilipBB commented Nov 17, 2016

I was able to merge my recent feature additions with your new file layout. I also added the ability to parse urls with spaces or other funny coded symbols: f8c7c97

Fixes issue #7

Filip Balos added 9 commits June 13, 2016 02:32
Adds shell completion support for arguments and feed names through
'argcomplete' (https://github.com/kislyuk/argcomplete) and lets
argparse handle more of the argument validation.

-Specified 'nargs' explicitly for the arguments that call the custom
action. For options with one argument, nargs, if unspecified, will return
a string, for options with more than one argument it will return a list.
It seems simpler just to make it always return a list. For this reason
some calls to args['names'] in greg.py were changed to args['names'][0].
-Fixed setting argument choices for arguments that take feed names as
input.

-Adds opml import/export using the 'opml' argument.

-Argcomplete is not working with the custom argparse action used to set
choices. Need to figure out why not. Removed completion support for now.
Had to add the custom argparse action to argcomplete.safe_actions to get
it to parse the action.
Taken from
http://stackoverflow.com/questions/120951/how-can-i-normalize-a-url-in-python,
referring to http://bugs.python.org/issue918368.

Enclosure links with spaces in them were causing greg to fail when
attempting to download them, or store them in the list of seen
enclosures. This fix uses 'quote' from 'urllib' to replace funny
characters in the url with escape sequences. I.e. " " becomes "%20".
Lxml enables nicer formatting for opml export but it isn't necessary.
@manolomartinez
Copy link
Owner

Thanks a lot. I'll review it as soon as possible.

@manolomartinez
Copy link
Owner

So, I was making tests with the opml command and stumbled upon a feed that does not have a "version" attribute, which messes with line 307 of commands.py:

Traceback (most recent call last):
  File "/home/manolo/Scripts/Oggregator/greg/venv/lib/python3.6/site-packages/f
    return self.__getitem__(key)
  File "/home/manolo/Scripts/Oggregator/greg/venv/lib/python3.6/site-packages/f
    return dict.__getitem__(self, key)
KeyError: 'version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/manolo/Scripts/Oggregator/greg/venv/bin/greg", line 11, in <modul
    load_entry_point('Greg==0.4.7', 'console_scripts', 'greg')()
  File "/home/manolo/Scripts/Oggregator/greg/venv/lib/python3.6/site-packages/g
    function(vars(args))
  File "/home/manolo/Scripts/Oggregator/greg/venv/lib/python3.6/site-packages/g
    feedtype = aux.feedparser.parse(feedurl).version
  File "/home/manolo/Scripts/Oggregator/greg/venv/lib/python3.6/site-packages/f
    raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'version'

@manolomartinez
Copy link
Owner

Another thing I've noticed is that you have substituted sys.exit() with print in many instances. I'm fine with it, but at least I'd send that output to sys.stderr, thus: print("blahblah", file=sys.stderr, flush=True)

@manolomartinez
Copy link
Owner

I'd try to keep one convention on function names. I have_been_using_underscores, and you have added a number of camelCase functions.

@manolomartinez
Copy link
Owner

Still going through the PR! :-) Thanks a lot for the ton of work @FilipBB

@FilipBB
Copy link
Contributor Author

FilipBB commented Jan 27, 2017

Sure, thanks for the feedback Manolo. It's quite hacky because I don't have formal programming experience, so I don't know best practices. Let me know when you're done looking it over and I'll try to implement the changes you suggest and send a new PR.

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