]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-volume: refactors `api.lvm.Volume._format_tag_args`
authorGuillaume Abrioux <gabrioux@ibm.com>
Thu, 27 Feb 2025 10:22:18 +0000 (11:22 +0100)
committerGuillaume Abrioux <gabrioux@ibm.com>
Mon, 3 Mar 2025 09:46:10 +0000 (10:46 +0100)
This replaces the previous approach using `list(sump(zip(repeat(op), tag_args), ()))` with a
more explicit loop-based implementation.
This makes the logic clearer while maintaining the same functionality.

Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
src/ceph-volume/ceph_volume/api/lvm.py

index 8ddf7b3a39e996d5001b33e281a598d34c8fa7da..0e2c0463d3e709ecb91f7d1391128b9576b1d591 100644 (file)
@@ -6,7 +6,6 @@ set of utilities for interacting with LVM.
 import logging
 import os
 import uuid
-from itertools import repeat
 from math import floor
 from ceph_volume import process, util, conf
 from ceph_volume.exceptions import SizeAllocationError
@@ -885,9 +884,10 @@ class Volume:
             return report
 
     def _format_tag_args(self, op: str, tags: Dict[str, Any]) -> List[str]:
-        tag_args = ['{}={}'.format(k, v) for k, v in tags.items()]
-        # weird but efficient way of ziping two lists and getting a flat list
-        return list(sum(zip(repeat(op), tag_args), ()))
+        result: List[str] = []
+        for k, v in tags.items():
+            result.extend([op, f'{k}={v}'])
+        return result
 
     def clear_tags(self, keys: Optional[List[str]] = None) -> None:
         """