use 'True if COND else False' for bool conversions

faster than 'bool(COND)', especially on older Pythons < 3.11
This commit is contained in:
Mike Fährmann
2024-10-14 20:53:49 +02:00
parent c148e200a4
commit d68bb78f44
4 changed files with 14 additions and 12 deletions

View File

@@ -109,7 +109,7 @@ class CohostUserExtractor(CohostExtractor):
"projectHandle": self.groups[0],
"page": 0,
"options": {
"pinnedPostsAtTop" : bool(self.pinned),
"pinnedPostsAtTop" : True if self.pinned else False,
"hideReplies" : not self.replies,
"hideShares" : not self.shares,
"hideAsks" : not self.asks,

View File

@@ -1301,7 +1301,7 @@ class DeviantartOAuthAPI():
metadata = extractor.config("metadata", False)
if not metadata:
metadata = bool(extractor.extra)
metadata = True if extractor.extra else False
if metadata:
self.metadata = True

View File

@@ -63,7 +63,8 @@ class NozomiExtractor(Extractor):
yield Message.Directory, post
for post["num"], image in enumerate(images, 1):
post["filename"] = post["dataid"] = did = image["dataid"]
post["is_video"] = video = bool(image.get("is_video"))
post["is_video"] = video = \
True if image.get("is_video") else False
ext = image["type"]
if video: