@@ -53,7 +53,7 @@ def predicate(line):
5353
5454 def prefixed_lines ():
5555 for line in text .splitlines (True ):
56- yield ( prefix + line if predicate (line ) else line )
56+ yield prefix + line if predicate (line ) else line
5757
5858 return "" .join (prefixed_lines ())
5959
@@ -70,7 +70,7 @@ def configure(template_file, parameters, output_file):
7070 `parameters`.
7171 """
7272 updated_lines = []
73- with open (template_file , "r" ) as file_ :
73+ with open (template_file ) as file_ :
7474 lines = file_ .readlines ()
7575 for line in lines :
7676 append = True
@@ -87,7 +87,7 @@ def configure(template_file, parameters, output_file):
8787 value = indent (value , block_indent )
8888 newline_indent = " " * parameter_option (key , "newline_indent" )
8989 if value .strip () and parameter_option (key , "newline_if_set" ):
90- value = "\n %s \n %s" % ( value , newline_indent )
90+ value = f "\n { value } \n { newline_indent } "
9191 line = line .replace ("@%s@" % key , value )
9292 if append :
9393 updated_lines .append (line )
@@ -106,7 +106,7 @@ def update_wheel_pyproject_toml_parameters(package_env_config: dict):
106106 params = dict (ITK_PYPROJECT_PY_PARAMETERS )
107107
108108 # generator
109- params ["PYPROJECT_GENERATOR" ] = "python %s '%s'" % ( SCRIPT_NAME , wheel_name )
109+ params ["PYPROJECT_GENERATOR" ] = f "python { SCRIPT_NAME } ' { wheel_name } '"
110110
111111 # name
112112 if wheel_name == "itk-meta" :
@@ -190,7 +190,7 @@ def update_wheel_pyproject_toml_parameters(package_env_config: dict):
190190
191191
192192def get_wheel_names ():
193- with open (os .path .join (SCRIPT_DIR , "WHEEL_NAMES.txt" ), "r" ) as _file :
193+ with open (os .path .join (SCRIPT_DIR , "WHEEL_NAMES.txt" )) as _file :
194194 return [wheel_name .strip () for wheel_name in _file .readlines ()]
195195
196196
@@ -216,7 +216,7 @@ def get_wheel_dependencies():
216216 regex_group_depends = r"set\s*\(\s*ITK\_GROUP\_([a-zA-Z0-9\_\-]+)\_DEPENDS\s*([a-zA-Z0-9\_\-\s]*)\s*" # noqa: E501
217217 pattern = re .compile (regex_group_depends )
218218 version = get_version ()
219- with open (os .path .join (SCRIPT_DIR , ".." , "CMakeLists.txt" ), "r" ) as file_ :
219+ with open (os .path .join (SCRIPT_DIR , ".." , "CMakeLists.txt" )) as file_ :
220220 for line in file_ .readlines ():
221221 match = re .search (pattern , line )
222222 if not match :
@@ -235,18 +235,19 @@ def get_wheel_dependencies():
235235 all_depends ["itk-meta" ].append ("numpy" )
236236 return all_depends
237237
238+
238239def init_pyproject_globals (package_env_config ):
239240 global ITK_PYPROJECT_PY_PARAMETERS
240241 global PYPROJECT_PY_PARAMETERS
241242
242243 ITK_PYPROJECT_PY_PARAMETERS = {
243- "PYPROJECT_GENERATOR" : "python %s '%s'" % (SCRIPT_NAME , "itk" ),
244+ "PYPROJECT_GENERATOR" : "python {} '{}'" . format (SCRIPT_NAME , "itk" ),
244245 "PYPROJECT_NAME" : r"itk" ,
245246 "PYPROJECT_VERSION" : get_version (),
246247 "PYPROJECT_CMAKE_ARGS" : r"" ,
247248 "PYPROJECT_PY_API" : get_py_api (),
248249 "PYPROJECT_PLATLIB" : r"true" ,
249- "ITK_SOURCE_DIR" : package_env_config [' ITK_SOURCE_DIR' ],
250+ "ITK_SOURCE_DIR" : package_env_config [" ITK_SOURCE_DIR" ],
250251 "PYPROJECT_PY_MODULES" : list_to_str (
251252 [
252253 "itkBase" ,
0 commit comments