Skip to content

Commit 7b40bbc

Browse files
committed
Add some more f strings
1 parent c7cf483 commit 7b40bbc

9 files changed

Lines changed: 14 additions & 14 deletions

File tree

lib/createsend/campaign.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,4 @@ def bounces(self, date="", page=1, page_size=1000, order_field="date", order_dir
188188
return json_to_py(response)
189189

190190
def uri_for(self, action):
191-
return "/campaigns/{}/{}.json".format(self.campaign_id, action)
191+
return f"/campaigns/{self.campaign_id}/{action}.json"

lib/createsend/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,4 @@ def journeys(self):
184184
return json_to_py(response)
185185

186186
def uri_for(self, action):
187-
return "/clients/{}/{}.json".format(self.client_id, action)
187+
return f"/clients/{self.client_id}/{action}.json"

lib/createsend/createsend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __str__(self):
2424
# self.data should contain Code, Message and optionally ResultData
2525
extra = ("\nExtra result data: %s" % self.data.ResultData) if hasattr(
2626
self.data, 'ResultData') else ""
27-
return "The CreateSend API responded with the following error - {}: {}{}".format(self.data.Code, self.data.Message, extra)
27+
return f"The CreateSend API responded with the following error - {self.data.Code}: {self.data.Message}{extra}"
2828

2929

3030
class ClientError(Exception):
@@ -75,7 +75,7 @@ def authorize_url(self, client_id, redirect_uri, scope, state=None):
7575
]
7676
if state:
7777
params.append(('state', state))
78-
return "{}?{}".format(CreateSend.oauth_uri, urlencode(params))
78+
return f"{CreateSend.oauth_uri}?{urlencode(params)}"
7979

8080
def exchange_token(self, client_id, client_secret, redirect_uri, code):
8181
"""Exchange a provided OAuth code for an OAuth access token, 'expires in'
@@ -93,7 +93,7 @@ def exchange_token(self, client_id, client_secret, redirect_uri, code):
9393
r = json_to_py(response)
9494
if hasattr(r, 'error') and hasattr(r, 'error_description'):
9595
err = "Error exchanging code for access token: "
96-
err += "{} - {}".format(r.error, r.error_description)
96+
err += f"{r.error} - {r.error_description}"
9797
raise Exception(err)
9898
access_token, expires_in, refresh_token = r.access_token, r.expires_in, r.refresh_token
9999
return [access_token, expires_in, refresh_token]
@@ -154,7 +154,7 @@ def make_request(self, method, path, params={}, body="", username=None,
154154
overridden (e.g. when using the apikey route with username and password)."""
155155
if username and password:
156156
headers['Authorization'] = "Basic %s" % base64.b64encode(
157-
("{}:{}".format(username, password)).encode()).decode()
157+
(f"{username}:{password}").encode()).decode()
158158
elif self.auth_details:
159159
if 'api_key' in self.auth_details and self.auth_details['api_key']:
160160
headers['Authorization'] = "Basic %s" % base64.b64encode(

lib/createsend/journey_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ def get_journey_email_response(self, date, page, page_size, order_direction, uri
4444
return json_to_py(response)
4545

4646
def uri_for(self, action):
47-
return "/journeys/email/{}/{}.json".format(self.journey_email_id, action)
47+
return f"/journeys/email/{self.journey_email_id}/{action}.json"
4848

lib/createsend/list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,4 @@ def deactivate_webhook(self, webhook_id):
204204
"webhooks/%s/deactivate" % webhook_id), ' ')
205205

206206
def uri_for(self, action):
207-
return "/lists/{}/{}.json".format(self.list_id, action)
207+
return f"/lists/{self.list_id}/{action}.json"

lib/createsend/segment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ def delete(self):
6161
response = self._delete("/segments/%s.json" % self.segment_id)
6262

6363
def uri_for(self, action):
64-
return "/segments/{}/{}.json".format(self.segment_id, action)
64+
return f"/segments/{self.segment_id}/{action}.json"

lib/createsend/transactional.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def smart_email_list(self, status="all", client_id=None):
1818
"/transactional/smartEmail?status=%s" % status)
1919
else:
2020
response = self._get(
21-
"/transactional/smartEmail?status={}&clientID={}".format(status, client_id))
21+
f"/transactional/smartEmail?status={status}&clientID={client_id}")
2222
return json_to_py(response)
2323

2424
def smart_email_details(self, smart_email_id):
@@ -91,7 +91,7 @@ def message_timeline(self, params={}):
9191
def message_details(self, message_id, statistics=False, exclude_message_body=False):
9292
"""Gets the details of this message."""
9393
response = self._get(
94-
"/transactional/messages/{}?statistics={}&excludemessagebody={}".format(message_id, statistics, exclude_message_body))
94+
f"/transactional/messages/{message_id}?statistics={statistics}&excludemessagebody={exclude_message_body}")
9595
return json_to_py(response)
9696

9797
def message_resend(self, message_id):

lib/createsend/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def validate_consent_to_track(user_input):
143143
user_input = user_input.lower()
144144
if user_input in VALID_CONSENT_TO_TRACK_VALUES:
145145
return
146-
raise ClientError("Consent to track value must be one of {}".format(VALID_CONSENT_TO_TRACK_VALUES))
146+
raise ClientError(f"Consent to track value must be one of {VALID_CONSENT_TO_TRACK_VALUES}")
147147

148148

149149
def get_faker(expected_url, filename, status=None, body=None):
@@ -161,7 +161,7 @@ def __init__(self, expected_url, filename, status, body=None):
161161

162162
def open(self):
163163
if self.filename:
164-
return open("{}/../test/fixtures/{}".format(os.path.dirname(os.path.dirname(__file__)), self.filename), mode='rb').read()
164+
return open(f"{os.path.dirname(os.path.dirname(__file__))}/../test/fixtures/{self.filename}", mode='rb').read()
165165
else:
166166
return ''
167167

samples/general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
# Get list of clients
1111
for cl in clients:
12-
print("Client: {} - Id: {}".format(cl.Name, cl.ClientID))
12+
print(f"Client: {cl.Name} - Id: {cl.ClientID}")

0 commit comments

Comments
 (0)