Skip to content

Commit e1d1458

Browse files
committed
Replace format methods by F-strings
1 parent 015f918 commit e1d1458

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

utils/autotailor

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,22 @@ class Tailoring:
8181
elif attribute == "severity":
8282
enumeration = SEVERITIES
8383
else:
84-
msg = (
85-
"Unsupported refine-rule attribute {attribute}".format(
86-
attribute=attribute))
84+
msg = f"Unsupported refine-rule attribute {attribute}"
8785
raise ValueError(msg)
8886
return enumeration
8987

9088
@staticmethod
9189
def _validate_rule_refinement_params(rule_id, attribute, value):
9290
if not is_valid_xccdf_id(rule_id):
93-
msg = "Rule id '{rule_id}' is invalid!".format(rule_id=rule_id)
91+
msg = f"Rule id '{rule_id}' is invalid!"
9492
raise ValueError(msg)
9593
enumeration = Tailoring._find_enumeration(attribute)
9694
if value in enumeration:
9795
return
9896
allowed = ", ".join(map(quote, enumeration))
9997
msg = (
100-
"Can't refine {attribute} of rule '{rule_id}' to '{value}'. "
101-
"Allowed {attribute} values are: {allowed}.".format(
102-
attribute=attribute, rule_id=rule_id, value=value,
103-
allowed=allowed))
98+
f"Can't refine {attribute} of rule '{rule_id}' to '{value}'. "
99+
f"Allowed {attribute} values are: {allowed}.")
104100
raise ValueError(msg)
105101

106102
def _prevent_duplicate_rule_refinement(self, attribute, rule_id, value):
@@ -109,10 +105,8 @@ class Tailoring:
109105
return
110106
current = refinements[attribute]
111107
msg = (
112-
"Can't refine {attribute} of rule '{rule_id}' to '{value}'. "
113-
"This rule {attribute} is already refined to '{current}'.".format(
114-
attribute=attribute, rule_id=rule_id, value=value,
115-
current=current))
108+
f"Can't refine {attribute} of rule '{rule_id}' to '{value}'. "
109+
f"This rule {attribute} is already refined to '{current}'.")
116110
raise ValueError(msg)
117111

118112
def refine_rule(self, rule_id, attribute, value):
@@ -140,9 +134,7 @@ class Tailoring:
140134
def _full_id(self, string, el_type):
141135
if is_valid_xccdf_id(string):
142136
return string
143-
default_prefix = "xccdf_{namespace}_{el_type}_".format(
144-
namespace=self.reverse_dns, el_type=el_type)
145-
return default_prefix + string
137+
return f"xccdf_{self.reverse_dns}_{el_type}_{string}"
146138

147139
def _full_profile_id(self, string):
148140
return self._full_id(string, "profile")

0 commit comments

Comments
 (0)