replace old %-formatted and .format(…) strings with f-strings (#7671)

mostly using flynt
https://github.com/ikamensh/flynt
This commit is contained in:
Mike Fährmann
2025-06-28 19:36:16 +02:00
parent f77e98b57d
commit 9dbe33b6de
167 changed files with 756 additions and 891 deletions

View File

@@ -101,7 +101,7 @@ class ArtstationExtractor(Extractor):
def get_project_assets(self, project_id):
"""Return all assets associated with 'project_id'"""
url = "{}/projects/{}.json".format(self.root, project_id)
url = f"{self.root}/projects/{project_id}.json"
try:
data = self.request(url).json()
@@ -129,7 +129,7 @@ class ArtstationExtractor(Extractor):
def get_user_info(self, username):
"""Return metadata for a specific user"""
url = "{}/users/{}/quick.json".format(self.root, username.lower())
url = f"{self.root}/users/{username.lower()}/quick.json"
response = self.request(url, notfound="user")
return response.json()
@@ -197,7 +197,7 @@ class ArtstationUserExtractor(ArtstationExtractor):
example = "https://www.artstation.com/USER"
def projects(self):
url = "{}/users/{}/projects.json".format(self.root, self.user)
url = f"{self.root}/users/{self.user}/projects.json"
params = {"album_id": "all"}
return self._pagination(url, params)
@@ -233,7 +233,7 @@ class ArtstationAlbumExtractor(ArtstationExtractor):
}
def projects(self):
url = "{}/users/{}/projects.json".format(self.root, self.user)
url = f"{self.root}/users/{self.user}/projects.json"
params = {"album_id": self.album_id}
return self._pagination(url, params)
@@ -248,7 +248,7 @@ class ArtstationLikesExtractor(ArtstationExtractor):
example = "https://www.artstation.com/USER/likes"
def projects(self):
url = "{}/users/{}/likes.json".format(self.root, self.user)
url = f"{self.root}/users/{self.user}/likes.json"
return self._pagination(url)
@@ -267,16 +267,14 @@ class ArtstationCollectionExtractor(ArtstationExtractor):
self.collection_id = match[2]
def metadata(self):
url = "{}/collections/{}.json".format(
self.root, self.collection_id)
url = f"{self.root}/collections/{self.collection_id}.json"
params = {"username": self.user}
collection = self.request(
url, params=params, notfound="collection").json()
return {"collection": collection, "user": self.user}
def projects(self):
url = "{}/collections/{}/projects.json".format(
self.root, self.collection_id)
url = f"{self.root}/collections/{self.collection_id}/projects.json"
params = {"collection_id": self.collection_id}
return self._pagination(url, params)
@@ -294,8 +292,7 @@ class ArtstationCollectionsExtractor(ArtstationExtractor):
for collection in self.request(
url, params=params, notfound="collections").json():
url = "{}/{}/collections/{}".format(
self.root, self.user, collection["id"])
url = f"{self.root}/{self.user}/collections/{collection['id']}"
collection["_extractor"] = ArtstationCollectionExtractor
yield Message.Queue, url, collection
@@ -318,12 +315,10 @@ class ArtstationChallengeExtractor(ArtstationExtractor):
self.sorting = match[2] or "popular"
def items(self):
challenge_url = "{}/contests/_/challenges/{}.json".format(
self.root, self.challenge_id)
submission_url = "{}/contests/_/challenges/{}/submissions.json".format(
self.root, self.challenge_id)
update_url = "{}/contests/submission_updates.json".format(
self.root)
base = f"{self.root}/contests/_/challenges/{self.challenge_id}"
challenge_url = f"{base}.json"
submission_url = f"{base}/submissions.json"
update_url = f"{self.root}/contests/submission_updates.json"
challenge = self.request(challenge_url).json()
yield Message.Directory, {"challenge": challenge}
@@ -381,7 +376,7 @@ class ArtstationSearchExtractor(ArtstationExtractor):
"value" : value.split(","),
})
url = "{}/api/v2/search/projects.json".format(self.root)
url = f"{self.root}/api/v2/search/projects.json"
data = {
"query" : self.query,
"page" : None,
@@ -412,7 +407,7 @@ class ArtstationArtworkExtractor(ArtstationExtractor):
return {"artwork": self.query}
def projects(self):
url = "{}/projects.json".format(self.root)
url = f"{self.root}/projects.json"
return self._pagination(url, self.query.copy())
@@ -453,8 +448,8 @@ class ArtstationFollowingExtractor(ArtstationExtractor):
example = "https://www.artstation.com/USER/following"
def items(self):
url = "{}/users/{}/following.json".format(self.root, self.user)
url = f"{self.root}/users/{self.user}/following.json"
for user in self._pagination(url):
url = "{}/{}".format(self.root, user["username"])
url = f"{self.root}/{user['username']}"
user["_extractor"] = ArtstationUserExtractor
yield Message.Queue, url, user