XZise has uploaded a new change for review. https://gerrit.wikimedia.org/r/181076
Change subject: [IMPROV] Site: Document getFilesFromAnHash properly ...................................................................... [IMPROV] Site: Document getFilesFromAnHash properly This adds a proper documentation to this method (and getImagesFromAnHash) and includes a warning if the hash is set to None (in the future this parameter shouldn't be optional). Change-Id: Ia37b18dc0c587071ea3b0bf5a3ebee7ae2d01504 --- M pywikibot/site.py 1 file changed, 18 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/76/181076/1 diff --git a/pywikibot/site.py b/pywikibot/site.py index 8f82568..5241536 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4405,23 +4405,33 @@ return self.exturlusage(siteurl, total=limit) def getFilesFromAnHash(self, hash_found=None): - """Return all images that have the same hash. + """ + Return all files with the given hash. - Useful to find duplicates or nowcommons. - - NOTE: it returns also the image itself, if you don't want it, just - filter the list returned. - - NOTE 2: it returns the image title WITHOUT the image namespace. - + @param hash_found: The has of the file. Although it's marked as + optional this method always returns None if the has is None and + it makes no sense to use the default value. + @type hash_found: basestring representing the SHA1 hash + @return: All file titles which belong to the same hash, without a + namespace. + @rtype: list of basestring """ if hash_found is None: + # This makes absolutely NO sense. + pywikibot.warning( + 'The "hash_found" parameter in "getFilesFromAnHash" and ' + '"getImagesFromAnHash" are not optional.') return return [image.title(withNamespace=False) for image in self.allimages(sha1=hash_found)] @deprecated('Site().getFilesFromAnHash') def getImagesFromAnHash(self, hash_found=None): + """ + Return all images that have the same hash. + + DEPRECATED: Use getFilesFromAnHash instead. + """ return self.getFilesFromAnHash(hash_found) @must_be(group='user') -- To view, visit https://gerrit.wikimedia.org/r/181076 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia37b18dc0c587071ea3b0bf5a3ebee7ae2d01504 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: XZise <commodorefabia...@gmx.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits