Skip to content

Commit e189f76

Browse files
committed
[ot] python/qemu: ot: use removeprefix() when possible
Signed-off-by: Emmanuel Blot <[email protected]>
1 parent 1db9dfd commit e189f76

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

python/qemu/ot/km/dpe.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,10 @@ def load_config(self, config_file: TextIO) -> None:
176176
self._config.read_file(config_file)
177177
loaded: set[str] = set()
178178
for section in self._config.sections():
179-
if not section.startswith('ot_device '):
179+
prefix = 'ot_device '
180+
if not section.startswith(prefix):
180181
continue
181-
devname = section[len('ot_device '):].strip(' "')
182+
devname = section.removeprefix(prefix).strip(' "')
182183
devdescs = devname.split('.')
183184
devtype = devdescs[0]
184185
if devtype == 'ot-lc_ctrl' and devtype not in loaded:

python/qemu/ot/otp/map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def _check_keymgr_materials(self, partname: str, items: dict[str, dict]) \
155155
for props in items.values():
156156
for prop, value in props.items():
157157
if prop.startswith(kmprefix):
158-
kind = prop[len(kmprefix):]
158+
kind = prop.removeprefix(kmprefix)
159159
if kind not in kms:
160160
kms[kind] = set()
161161
kms[kind].add(value)

python/qemu/ot/pyot/wrapper.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,7 @@ def trig_match(bline):
356356
self._post_process_asan(asan_file)
357357
xtime = ExecTime(xend-xstart) if xstart and xend else 0.0
358358
app_cmd_lead = f'{basename(tdef.command[0])}: '
359-
if last_error.startswith(app_cmd_lead):
360-
last_error = last_error[len(app_cmd_lead):]
361-
return abs(ret) or 0, xtime, last_error
359+
return abs(ret) or 0, xtime, last_error.removeprefix(app_cmd_lead)
362360

363361
@classmethod
364362
def classify_log(cls, line: str, default: int = logging.ERROR,

0 commit comments

Comments
 (0)