From: John Mulligan Date: Mon, 7 Oct 2024 18:51:13 +0000 (-0400) Subject: cephadm: invert if statement in list_daemons X-Git-Tag: v20.3.0~256^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f39f2e8c9723edd92b27d00460eced65c194c591;p=ceph.git cephadm: invert if statement in list_daemons Invert an if-statement within the list_daemons function and thus remove an unnecessary and somewhat confusing extra level of indentation (as it defines a bunch of vars that are used later outside the indented block). This should be logically identical to the previous code. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index a695b4beb39b..2ca89b7f8d2f 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -3469,18 +3469,18 @@ def list_daemons( elif is_fsid(i): fsid = str(i) # convince mypy that fsid is a str here for j in os.listdir(os.path.join(data_dir, i)): - if '.' in j and os.path.isdir( - os.path.join(data_dir, fsid, j) + if not ( + '.' in j + and os.path.isdir(os.path.join(data_dir, fsid, j)) ): - name = j - if daemon_name and name != daemon_name: - continue - (daemon_type, daemon_id) = j.split('.', 1) - if type_of_daemon and type_of_daemon != daemon_type: - continue - unit_name = get_unit_name(fsid, daemon_type, daemon_id) - else: continue + name = j + if daemon_name and name != daemon_name: + continue + (daemon_type, daemon_id) = j.split('.', 1) + if type_of_daemon and type_of_daemon != daemon_type: + continue + unit_name = get_unit_name(fsid, daemon_type, daemon_id) val = { 'style': 'cephadm:v1', 'name': name,