Page MenuHomePhabricator

Remove default values in flickrripper script
Closed, ResolvedPublic

Description

The flickrripper script uses default values for all parameters which is not always sensible. For example the following function can't work when not both parameters are given:

def getPhoto(flickr=None, photo_id=''):                                         
    """                                                                         
    Get the photo info and the photo sizes so we can use these later on.        
                                                                                
    TODO: Add exception handling                                                
                                                                                
    """                                                                         
    while True:                                                                 
        try:                                                                    
            photoInfo = flickr.photos_getInfo(photo_id=photo_id)                
            # xml.etree.ElementTree.dump(photoInfo)                             
            photoSizes = flickr.photos_getSizes(photo_id=photo_id)              
            # xml.etree.ElementTree.dump(photoSizes)                            
            return photoInfo, photoSizes                                        
        except flickrapi.exceptions.FlickrError:                                
            pywikibot.output(u'Flickr api problem, sleeping')                   
            time.sleep(30)

Event Timeline

XZise raised the priority of this task from to Lowest.
XZise updated the task description. (Show Details)
XZise added projects: Pywikibot, good first task.
XZise subscribed.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptMar 18 2015, 4:50 PM

I'm new to Pywikibot, but I think I can take this up.
Looking at "scripts/flickrripper.py" and https://www.flickr.com/services/api/ .

Changes I'm making in my patch:

def getPhoto(flickr=None, photo_id='') --> def getPhoto(flickr, photo_id)
def isAllowedLicense(photoInfo=None) --> def isAllowedLicense(photoInfo)
def getPhotoUrl(photoSizes=None) --> def getPhotoUrl(photoSizes)
.
.
.
def getPhotos(flickr=None, user_id=u'', group_id=u'', photoset_id=u'', start_id='', end_id='', tags=u'') --> def getPhotos(flick, user_id, group_id, photoset_id, start_id, end_id, tags)

Please correct me if this was not what was expected.

Change 273842 had a related patch set uploaded (by Darthbhyrava):
Change flickrripper:remove default values for all parameters\n Remove default values for all parameters to avoid errors in functions\n Bug: T93098

https://gerrit.wikimedia.org/r/273842

Added a patch.
@XZise @Xqt could you please review this and let me know if I am on the wrong track?
Thanks!

Change 273866 had a related patch set uploaded (by Darthbhyrava):
Change flickrripper:remove default values for all parameters

https://gerrit.wikimedia.org/r/273866

Change 273866 abandoned by Darthbhyrava:
Change flickrripper:remove default values for all parameters

Reason:
Should be an amend commit, not a duplicate one.

https://gerrit.wikimedia.org/r/273866

Change 273842 had a related patch set uploaded (by Darthbhyrava):
Change flickrripper:remove default values for parameters wherever necessary

https://gerrit.wikimedia.org/r/273842

Change 273842 merged by jenkins-bot:
Change flickrripper:remove default values for parameters wherever necessary

https://gerrit.wikimedia.org/r/273842

@darthbhyrava , the script panoramiopicker.py is nearly a copy of flickrripper.py, and has the same problem. If you like, you can fix this problem in panoramiopicker.py also.

@jayvdb sure, I'll take a look into that, too. :)
T129017

The patch has been merged, hence closing the task.