@@ -40,7 +40,7 @@ def __fill_rv_kernel_dir(self):
4040 if platform .system () != "Linux" :
4141 raise OSError ("I can only run on Linux." )
4242
43- kernel_path = os .path .join ("/lib/modules/%s/build" % platform .release (), self .rv_dir )
43+ kernel_path = os .path .join (f "/lib/modules/{ platform .release ()} /build" , self .rv_dir )
4444
4545 # if the current kernel is from a distro this may not be a full kernel tree
4646 # verify that one of the files we are going to modify is available
@@ -69,11 +69,11 @@ def _read_template_file(self, file):
6969 return self ._read_file (path )
7070
7171 def fill_parent (self ):
72- return "&rv_%s" % self .parent if self .parent else "NULL"
72+ return f "&rv_{ self .parent } " if self .parent else "NULL"
7373
7474 def fill_include_parent (self ):
7575 if self .parent :
76- return "#include <monitors/%s/%s. h>\n " % ( self . parent , self . parent )
76+ return f "#include <monitors/{ self . parent } / { self . parent } . h>\n "
7777 return ""
7878
7979 def fill_tracepoint_handlers_skel (self ):
@@ -119,7 +119,7 @@ def fill_monitor_deps(self):
119119 buff = []
120120 buff .append (" # XXX: add dependencies if there" )
121121 if self .parent :
122- buff .append (" depends on RV_MON_%s" % self .parent .upper ())
122+ buff .append (f " depends on RV_MON_{ self .parent .upper ()} " )
123123 buff .append (" default y" )
124124 return '\n ' .join (buff )
125125
@@ -145,50 +145,49 @@ def fill_tracepoint_tooltip(self):
145145 monitor_class_type = self .fill_monitor_class_type ()
146146 if self .auto_patch :
147147 self ._patch_file ("rv_trace.h" ,
148- "// Add new monitors based on CONFIG_%s here" % monitor_class_type ,
149- "#include <monitors/%s/%s_trace.h>" % ( self .name , self .name ) )
150- return " - Patching %s /rv_trace.h, double check the result" % self . rv_dir
148+ f "// Add new monitors based on CONFIG_{ monitor_class_type } here" ,
149+ f "#include <monitors/{ self .name } / { self .name } _trace.h>" )
150+ return f " - Patching { self . rv_dir } /rv_trace.h, double check the result"
151151
152- return """ - Edit %s /rv_trace.h:
153- Add this line where other tracepoints are included and %s is defined:
154- #include <monitors/%s/%s_trace .h>
155- """ % ( self . rv_dir , monitor_class_type , self . name , self . name )
152+ return f """ - Edit { self . rv_dir } /rv_trace.h:
153+ Add this line where other tracepoints are included and { monitor_class_type } is defined:
154+ #include <monitors/{ self . name } / { self . name } _trace .h>
155+ """
156156
157157 def _kconfig_marker (self , container = None ) -> str :
158- return "# Add new %smonitors here" % (container + " "
159- if container else "" )
158+ return f"# Add new { container + ' ' if container else '' } monitors here"
160159
161160 def fill_kconfig_tooltip (self ):
162161 if self .auto_patch :
163162 # monitors with a container should stay together in the Kconfig
164163 self ._patch_file ("Kconfig" ,
165164 self ._kconfig_marker (self .parent ),
166- "source \" kernel/trace/rv/monitors/%s /Kconfig\" " % ( self . name ) )
167- return " - Patching %s /Kconfig, double check the result" % self . rv_dir
165+ f "source \" kernel/trace/rv/monitors/{ self . name } /Kconfig\" " )
166+ return f " - Patching { self . rv_dir } /Kconfig, double check the result"
168167
169- return """ - Edit %s /Kconfig:
168+ return f """ - Edit { self . rv_dir } /Kconfig:
170169Add this line where other monitors are included:
171- source \" kernel/trace/rv/monitors/%s /Kconfig\"
172- """ % ( self . rv_dir , self . name )
170+ source \" kernel/trace/rv/monitors/{ self . name } /Kconfig\"
171+ """
173172
174173 def fill_makefile_tooltip (self ):
175174 name = self .name
176175 name_up = name .upper ()
177176 if self .auto_patch :
178177 self ._patch_file ("Makefile" ,
179178 "# Add new monitors here" ,
180- "obj-$(CONFIG_RV_MON_%s ) += monitors/%s/%s .o" % ( name_up , name , name ) )
181- return " - Patching %s /Makefile, double check the result" % self . rv_dir
179+ f "obj-$(CONFIG_RV_MON_{ name_up } ) += monitors/{ name } / { name } .o" )
180+ return f " - Patching { self . rv_dir } /Makefile, double check the result"
182181
183- return """ - Edit %s /Makefile:
182+ return f """ - Edit { self . rv_dir } /Makefile:
184183Add this line where other monitors are included:
185- obj-$(CONFIG_RV_MON_%s ) += monitors/%s/%s .o
186- """ % ( self . rv_dir , name_up , name , name )
184+ obj-$(CONFIG_RV_MON_{ name_up } ) += monitors/{ name } / { name } .o
185+ """
187186
188187 def fill_monitor_tooltip (self ):
189188 if self .auto_patch :
190- return " - Monitor created in %s /monitors/%s" % ( self .rv_dir , self . name )
191- return " - Move %s / to the kernel's monitor directory (%s/monitors)" % ( self .name , self . rv_dir )
189+ return f " - Monitor created in { self . rv_dir } /monitors/{ self .name } "
190+ return f " - Move { self . name } / to the kernel's monitor directory ({ self .rv_dir } /monitors)"
192191
193192 def __create_directory (self ):
194193 path = self .name
@@ -205,13 +204,13 @@ def __write_file(self, file_name, content):
205204 file .close ()
206205
207206 def _create_file (self , file_name , content ):
208- path = "%s/%s" % ( self .name , file_name )
207+ path = f" { self .name } / { file_name } "
209208 if self .auto_patch :
210209 path = os .path .join (self .rv_dir , "monitors" , path )
211210 self .__write_file (path , content )
212211
213212 def __get_main_name (self ):
214- path = "%s/%s" % ( self .name , " main.c")
213+ path = f" { self .name } / main.c"
215214 if not os .path .exists (path ):
216215 return "main.c"
217216 return "__main.c"
@@ -221,11 +220,11 @@ def print_files(self):
221220
222221 self .__create_directory ()
223222
224- path = "%s.c" % self .name
223+ path = f" { self .name } .c"
225224 self ._create_file (path , main_c )
226225
227226 model_h = self .fill_model_h ()
228- path = "%s.h" % self .name
227+ path = f" { self .name } .h"
229228 self ._create_file (path , model_h )
230229
231230 kconfig = self .fill_kconfig ()
@@ -258,5 +257,5 @@ def fill_trace_h(self):
258257 def print_files (self ):
259258 super ().print_files ()
260259 trace_h = self .fill_trace_h ()
261- path = "%s_trace.h" % self .name
260+ path = f" { self .name } _trace.h"
262261 self ._create_file (path , trace_h )
0 commit comments