Techdebt: Replace string-format with f-strings (for l* dirs) (#5685)
This commit is contained in:
parent
efeb110d06
commit
22b6205f1f
@ -17,9 +17,7 @@ class InvalidParameterException(LogsClientError):
|
||||
def __init__(self, msg=None, constraint=None, parameter=None, value=None):
|
||||
self.code = 400
|
||||
if constraint:
|
||||
msg = "1 validation error detected: Value '{}' at '{}' failed to satisfy constraint: {}".format(
|
||||
value, parameter, constraint
|
||||
)
|
||||
msg = f"1 validation error detected: Value '{value}' at '{parameter}' failed to satisfy constraint: {constraint}"
|
||||
super().__init__(
|
||||
"InvalidParameterException", msg or "A parameter is specified incorrectly."
|
||||
)
|
||||
|
@ -152,7 +152,7 @@ class LogStream(BaseModel):
|
||||
formatted_log_events,
|
||||
)
|
||||
|
||||
return "{:056d}".format(self.upload_sequence_token)
|
||||
return f"{self.upload_sequence_token:056d}"
|
||||
|
||||
def get_log_events(
|
||||
self,
|
||||
@ -211,26 +211,18 @@ class LogStream(BaseModel):
|
||||
if start_index < 0:
|
||||
start_index = 0
|
||||
elif start_index > final_index:
|
||||
return (
|
||||
[],
|
||||
"b/{:056d}".format(final_index),
|
||||
"f/{:056d}".format(final_index),
|
||||
)
|
||||
return ([], f"b/{final_index:056d}", f"f/{final_index:056d}")
|
||||
|
||||
if end_index > final_index:
|
||||
end_index = final_index
|
||||
elif end_index < 0:
|
||||
return ([], "b/{:056d}".format(0), "f/{:056d}".format(0))
|
||||
return ([], f"b/{0:056d}", f"f/{0:056d}")
|
||||
|
||||
events_page = [
|
||||
event.to_response_dict() for event in events[start_index : end_index + 1]
|
||||
]
|
||||
|
||||
return (
|
||||
events_page,
|
||||
"b/{:056d}".format(start_index),
|
||||
"f/{:056d}".format(end_index),
|
||||
)
|
||||
return (events_page, f"b/{start_index:056d}", f"f/{end_index:056d}")
|
||||
|
||||
def filter_log_events(self, start_time, end_time, filter_pattern):
|
||||
def filter_func(event):
|
||||
@ -358,9 +350,7 @@ class LogGroup(CloudFormationModel):
|
||||
log_streams_page = [x[1] for x in log_streams[first_index:last_index]]
|
||||
new_token = None
|
||||
if log_streams_page and last_index < len(log_streams):
|
||||
new_token = "{}@{}".format(
|
||||
log_group_name, log_streams_page[-1]["logStreamName"]
|
||||
)
|
||||
new_token = f"{log_group_name}@{log_streams_page[-1]['logStreamName']}"
|
||||
|
||||
return log_streams_page, new_token
|
||||
|
||||
@ -442,9 +432,7 @@ class LogGroup(CloudFormationModel):
|
||||
next_token = None
|
||||
if events_page and last_index < len(events):
|
||||
last_event = events_page[-1]
|
||||
next_token = "{}@{}@{}".format(
|
||||
log_group_name, last_event["logStreamName"], last_event["eventId"]
|
||||
)
|
||||
next_token = f"{log_group_name}@{last_event['logStreamName']}@{last_event['eventId']}"
|
||||
|
||||
searched_streams = [
|
||||
{"logStreamName": stream.log_stream_name, "searchedCompletely": True}
|
||||
|
@ -383,7 +383,7 @@ class LogsResponse(BaseResponse):
|
||||
log_group_names, start_time, end_time, query_string
|
||||
)
|
||||
|
||||
return json.dumps({"queryId": "{0}".format(query_id)})
|
||||
return json.dumps({"queryId": f"{query_id}"})
|
||||
|
||||
def create_export_task(self):
|
||||
log_group_name = self._get_param("logGroupName")
|
||||
|
Loading…
Reference in New Issue
Block a user