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:
parent
5a210991b6
commit
f5039b897f
@ -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,))
|
||||
|
Loading…
Reference in New Issue
Block a user