jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Site: Also deprecate getFilesFromAnHash ......................................................................
[IMPROV] Site: Also deprecate getFilesFromAnHash
This deprecates the getFilesFromAnHash method too because it's not PEP8-compliant and APISite.allimages provides the same functionality including being more flexible.
Change-Id: Ia37b18dc0c587071ea3b0bf5a3ebee7ae2d01504 --- M pywikibot/site.py 1 file changed, 23 insertions(+), 13 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index 8f82568..b1e9c7d 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4404,25 +4404,35 @@ """Backwards-compatible interface to exturlusage().""" return self.exturlusage(siteurl, total=limit)
- def getFilesFromAnHash(self, hash_found=None): - """Return all images that have the same 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. - - """ + def _get_titles_with_hash(self, hash_found=None): + """Helper for the deprecated method get(Files|Images)FromAnHash.""" + # This should be removed with together with get(Files|Images)FromHash 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') + @deprecated('Site().allimages') + def getFilesFromAnHash(self, hash_found=None): + """ + Return all files that have the same hash. + + DEPRECATED: Use L{APISite.allimages} instead using 'sha1'. + """ + return self._get_titles_with_hash(hash_found) + + @deprecated('Site().allimages') def getImagesFromAnHash(self, hash_found=None): - return self.getFilesFromAnHash(hash_found) + """ + Return all images that have the same hash. + + DEPRECATED: Use L{APISite.allimages} instead using 'sha1'. + """ + return self._get_titles_with_hash(hash_found)
@must_be(group='user') def is_uploaddisabled(self):