mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-04 15:21:12 +00:00
examples: improve finding last checkpoint in "checkpoint.py"
This is a python example. We should do nice things, like using max() for finding the maximum, instead of sorting.
This commit is contained in:
parent
6a04bcc59d
commit
3ce3ed4c92
|
@ -71,11 +71,11 @@ def find_checkpoint(nmc, path):
|
|||
|
||||
|
||||
def find_checkpoint_last(nmc):
|
||||
l = [c.get_path() for c in nmc.get_checkpoints()]
|
||||
if not l:
|
||||
return None
|
||||
l.sort(key=checkpoint_path_to_num)
|
||||
return l[-1]
|
||||
return max(
|
||||
nmc.get_checkpoints(),
|
||||
key=lambda c: checkpoint_path_to_num(c.get_path()),
|
||||
default=None,
|
||||
)
|
||||
|
||||
|
||||
def validate_path(path, nmc):
|
||||
|
|
Loading…
Reference in a new issue