1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 18:53:21 +01:00

replace DownloadArchive.check() with __contains__()

Interestingly enough, 'a in obj' is slightly faster than
'obj.check(a)' and is also nicer to look at, I think.
This commit is contained in:
Mike Fährmann 2019-08-16 21:18:56 +02:00
parent 5a210991b6
commit f5039b897f
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -566,7 +566,7 @@ class PathFormat():
def exists(self, archive=None):
"""Return True if the file exists on disk or in 'archive'"""
if archive and archive.check(self.kwdict):
if archive and self.kwdict in archive:
return self.fix_extension()
if self.extension and os.path.exists(self.realpath):
return self.check_file()
@ -719,8 +719,8 @@ class DownloadArchive():
"archive-format", extractor.archive_fmt)
).format_map
def check(self, kwdict):
"""Return True if item described by 'kwdict' exists in archive"""
def __contains__(self, kwdict):
"""Return True if the item described by 'kwdict' exists in archive"""
key = self.keygen(kwdict)
self.cursor.execute(
"SELECT 1 FROM archive WHERE entry=? LIMIT 1", (key,))