diff --git a/scripts/msvscpp-convert.py b/scripts/msvscpp-convert.py
index c08be41..d8030b9 100755
--- a/scripts/msvscpp-convert.py
+++ b/scripts/msvscpp-convert.py
@@ -91,7 +91,7 @@ def Main():
return False
if options.output_format not in output_formats:
- print('Unsupported output format: {0:s}.'.format(options.format_to))
+ print(f'Unsupported output format: {options.format_to:s}.')
print('')
return False
diff --git a/tests/test_lib.py b/tests/test_lib.py
index 5d36580..8446303 100644
--- a/tests/test_lib.py
+++ b/tests/test_lib.py
@@ -25,7 +25,7 @@ def skipUnlessHasTestFile(path_segments): # pylint: disable=invalid-name
# Note that the message should be of type str which is different for
# different versions of Python.
- return unittest.skip('missing test file: {0:s}'.format(path))
+ return unittest.skip(f'missing test file: {path:s}')
class BaseTestCase(unittest.TestCase):
diff --git a/vstools/resources.py b/vstools/resources.py
index f1e60c5..754bc03 100644
--- a/vstools/resources.py
+++ b/vstools/resources.py
@@ -58,8 +58,7 @@ def Append(self, configuration):
if configuration.platform not in self.platforms:
self.platforms.append(configuration.platform)
- identifier = '{0:s}|{1:s}'.format(
- configuration.name, configuration.platform)
+ identifier = '|'.join([configuration.name, configuration.platform])
self._configurations[identifier] = configuration
@@ -89,7 +88,7 @@ def GetByIdentifier(self, name, platform):
Returns:
VSConfiguration: configuration.
"""
- identifier = '{0:s}|{1:s}'.format(name, platform)
+ identifier = '|'.join([name, platform])
return self._configurations[identifier]
def GetSorted(self, reverse=False):
diff --git a/vstools/solutions.py b/vstools/solutions.py
index da180fe..27c7a48 100644
--- a/vstools/solutions.py
+++ b/vstools/solutions.py
@@ -64,7 +64,7 @@ def _ConvertProject(
project_reader = self._GetProjectFileReader(input_version)
- logging.info('Reading: {0:s}'.format(input_project_filename))
+ logging.info(f'Reading: {input_project_filename:s}')
project_reader.Open(input_project_filename)
@@ -98,8 +98,8 @@ def _ConvertProject(
project_configuration.additional_dependencies.remove(library_path)
library_path = (
- '..\\..\\..\\dokany\\dokan\\$(Platform)\\{0:s}\\'
- 'dokan1.lib').format(configuration)
+ f'..\\..\\..\\dokany\\dokan\\$(Platform)\\{configuration:s}\\'
+ f'dokan1.lib')
project_configuration.additional_dependencies.append(library_path)
@@ -120,12 +120,12 @@ def _ConvertProject(
if include_path in project_configuration.include_directories:
project_configuration.include_directories.remove(include_path)
project_configuration.include_directories.append(
- '{0:s}\\include'.format(self._python_path))
+ f'{self._python_path:s}\\include')
if library_path in project_configuration.library_directories:
project_configuration.library_directories.remove(library_path)
project_configuration.library_directories.append(
- '{0:s}\\libs'.format(self._python_path))
+ f'{self._python_path:s}\\libs')
if self._extend_with_x64:
# Add x64 as a platform.
@@ -148,9 +148,10 @@ def _GetProjectFilename(self, version, project_filename):
str: project filename with extension or None if version is not supported.
"""
if version == '2008':
- return '{0:s}.vcproj'.format(project_filename)
+ return f'{project_filename:s}.vcproj'
+
if version in ('2010', '2012', '2013', '2015', '2017', '2019', '2022'):
- return '{0:s}.vcxproj'.format(project_filename)
+ return f'{project_filename:s}.vcxproj'
return None
@@ -282,8 +283,7 @@ def _WriteProject(
solution_projects_by_guid (dict[str, VSSolutionProject]): projects
per lower case GUID.
"""
- output_directory = 'vs{0:s}'.format(output_version)
- output_project_filename = output_directory
+ output_project_filename = f'vs{output_version:s}'
for path_segment in solution_project.filename.split('\\'):
output_project_filename = os.path.join(
output_project_filename, path_segment)
@@ -297,7 +297,7 @@ def _WriteProject(
project_writer = self._GetProjectFileWriter(output_version)
- logging.info('Writing: {0:s}'.format(output_project_filename))
+ logging.info(f'Writing: {output_project_filename:s}')
project_writer.Open(output_project_filename)
project_writer.WriteHeader()
@@ -324,12 +324,12 @@ def _WriteSolution(
solution_projects (list[VSSolutionProject]): projects.
solution_configurations (VSConfigurations): configurations.
"""
- output_directory = 'vs{0:s}'.format(output_version)
+ output_directory = f'vs{output_version:s}'
os.mkdir(output_directory)
output_sln_filename = os.path.join(output_directory, solution_filename)
- logging.info('Writing: {0:s}'.format(output_sln_filename))
+ logging.info(f'Writing: {output_sln_filename:s}')
solution_writer = self._GetSolutionFileWriter(output_version)
@@ -353,7 +353,7 @@ def Convert(self, input_sln_path, output_version):
if not os.path.exists(input_sln_path):
return False
- logging.info('Reading: {0:s}'.format(input_sln_path))
+ logging.info(f'Reading: {input_sln_path:s}')
# TODO: detect input version based on solution file reader?
input_version = '2008'
diff --git a/vstools/writers.py b/vstools/writers.py
index b58136f..8bf8d1d 100644
--- a/vstools/writers.py
+++ b/vstools/writers.py
@@ -585,26 +585,29 @@ def _WriteConfigurationPropertyGroup(self, project_configuration):
"""
self._WriteConfigurationPropertyGroupHeader(project_configuration)
- self.WriteLine(' {0:s}'.format(
- project_configuration.output_type_string))
+ self.WriteLine((
+ f' '
+ f'{project_configuration.output_type_string:s}'
+ f''))
if project_configuration.character_set:
- self.WriteLine(' {0:s}'.format(
- project_configuration.character_set_string))
+ self.WriteLine((
+ f' {project_configuration.character_set_string:s}'
+ f''))
if project_configuration.managed_extensions == '1':
self.WriteLine(' true')
if project_configuration.whole_program_optimization:
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.whole_program_optimization_string))
+ f' '
+ f'{project_configuration.whole_program_optimization_string:s}'
+ f''))
platform_toolset = project_configuration.GetPlatformToolset(self._version)
if platform_toolset:
- self.WriteLine(' {0:s}'.format(
- platform_toolset))
+ self.WriteLine(
+ f' {platform_toolset:s}')
self._WriteConfigurationPropertyGroupFooter()
@@ -619,9 +622,9 @@ def _WriteConfigurationPropertyGroupHeader(self, project_configuration):
project_configuration (VSProjectConfiguration): project configuration.
"""
self.WriteLine((
- ' ').format(
- project_configuration.name, project_configuration.platform))
+ f' '))
def _WriteHeaderFiles(self, header_files):
"""Writes the header files.
@@ -633,7 +636,7 @@ def _WriteHeaderFiles(self, header_files):
self.WriteLine(' ')
for filename in header_files:
- self.WriteLine(' '.format(filename))
+ self.WriteLine(f' ')
self.WriteLine(' ')
@@ -671,9 +674,9 @@ def _WriteItemDefinitionGroupHeader(self, project_configuration):
project_configuration (VSProjectConfiguration): project configuration.
"""
self.WriteLine((
- ' ').format(
- project_configuration.name, project_configuration.platform))
+ f' '))
def _WriteLibrarianSection(self, project_configuration):
"""Writes the librarian section.
@@ -687,13 +690,13 @@ def _WriteLibrarianSection(self, project_configuration):
self.WriteLines([
' ',
- ' {0:s}'.format(librarian_output_file)])
+ f' {librarian_output_file:s}'])
if project_configuration.module_definition_file != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.module_definition_file))
+ f' '
+ f'{project_configuration.module_definition_file:s}'
+ f''))
else:
self.WriteLines([
' ',
@@ -701,9 +704,9 @@ def _WriteLibrarianSection(self, project_configuration):
if project_configuration.librarian_ignore_defaults != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.librarian_ignore_defaults))
+ f' '
+ f'{project_configuration.librarian_ignore_defaults:s}'
+ f''))
self.WriteLine(' ')
@@ -724,29 +727,27 @@ def _WriteLinkerSection(self, project_configuration):
r'[$][(]OutDir[)]\\', r'$(OutDir)', additional_dependencies)
if additional_dependencies and additional_dependencies[-1] != ';':
- additional_dependencies = '{0:s};'.format(additional_dependencies)
+ additional_dependencies = ''.join([additional_dependencies, ';'])
- additional_dependencies = '{0:s}%(AdditionalDependencies)'.format(
- additional_dependencies)
+ additional_dependencies = ''.join([
+ additional_dependencies, '%(AdditionalDependencies)'])
self.WriteLine((
- ' {0:s}'
- '').format(
- additional_dependencies))
+ f' {additional_dependencies:s}'
+ f''))
if project_configuration.linker_output_file:
linker_output_file = re.sub(
r'[$][(]OutDir[)]\\', r'$(OutDir)',
project_configuration.linker_output_file)
- self.WriteLine(' {0:s}'.format(
- linker_output_file))
+ self.WriteLine(f' {linker_output_file:s}')
if project_configuration.module_definition_file != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.module_definition_file))
+ f' '
+ f'{project_configuration.module_definition_file:s}'
+ f''))
if project_configuration.library_directories:
library_directories = ';'.join(project_configuration.library_directories)
@@ -755,25 +756,25 @@ def _WriteLinkerSection(self, project_configuration):
library_directories = re.sub(r'"', r'', library_directories)
if library_directories and library_directories[-1] != ';':
- library_directories = '{0:s};'.format(library_directories)
+ library_directories = ''.join([library_directories, ';'])
- library_directories = '{0:s}%(AdditionalLibraryDirectories)'.format(
- library_directories)
+ library_directories = ''.join([
+ library_directories, '%(AdditionalLibraryDirectories)'])
self.WriteLine((
- ' {0:s}'
- '').format(
- library_directories))
+ f' {library_directories:s}'
+ f''))
if project_configuration.generate_debug_information != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.generate_debug_information))
+ f' '
+ f'{project_configuration.generate_debug_information:s}'
+ f''))
if project_configuration.sub_system != '':
- self.WriteLine(' {0:s}'.format(
- project_configuration.sub_system_string))
+ self.WriteLine((
+ f' {project_configuration.sub_system_string:s}'
+ f''))
if project_configuration.optimize_references == '0':
self.WriteLines([
@@ -782,8 +783,9 @@ def _WriteLinkerSection(self, project_configuration):
elif project_configuration.optimize_references != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.optimize_references_string))
+ f' '
+ f'{project_configuration.optimize_references_string:s}'
+ f''))
if project_configuration.enable_comdat_folding == '0':
self.WriteLines([
@@ -792,14 +794,15 @@ def _WriteLinkerSection(self, project_configuration):
elif project_configuration.enable_comdat_folding != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.enable_comdat_folding_string))
+ f' '
+ f'{project_configuration.enable_comdat_folding_string:s}'
+ f''))
if project_configuration.randomized_base_address != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.randomized_base_address_string))
+ f' '
+ f'{project_configuration.randomized_base_address_string:s}'
+ f''))
if project_configuration.fixed_base_address == '0':
self.WriteLines([
@@ -814,21 +817,21 @@ def _WriteLinkerSection(self, project_configuration):
' '])
else:
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.data_execution_prevention_string))
+ f' '
+ f'{project_configuration.data_execution_prevention_string:s}'
+ f''))
if project_configuration.import_library:
import_library = re.sub(
r'[$][(]OutDir[)]\\', r'$(OutDir)',
project_configuration.import_library)
- self.WriteLine(' {0:s}'.format(
- import_library))
+ self.WriteLine(f' {import_library:s}')
if project_configuration.target_machine != '':
- self.WriteLine(' {0:s}'.format(
- project_configuration.target_machine_string))
+ self.WriteLine((
+ f' '
+ f'{project_configuration.target_machine_string:s}'))
self.WriteLine(' ')
@@ -846,16 +849,16 @@ def _WriteOutIntDirConditions(
if len(project_configurations.platforms) == 1:
self.WriteLine((
- ' $(SolutionDir)$(Configuration)\\'
- '').format(
- project_configuration.name, project_configuration.platform))
+ f' $(SolutionDir)'
+ f'$(Configuration)\\'))
else:
self.WriteLine((
- ' $(SolutionDir)$(Configuration)\\$(Platform)\\'
- '').format(
- project_configuration.name, project_configuration.platform))
+ f' $(SolutionDir)'
+ f'$(Configuration)\\$(Platform)\\'))
for configuration_platform in sorted(project_configurations.platforms):
project_configuration = project_configurations.GetByIdentifier(
@@ -863,14 +866,16 @@ def _WriteOutIntDirConditions(
if len(project_configurations.platforms) == 1:
self.WriteLine((
- ' $(Configuration)\\').format(
- project_configuration.name, project_configuration.platform))
+ f' '
+ f'$(Configuration)\\'))
else:
self.WriteLine((
- ' $(Configuration)\\$(Platform)\\').format(
- project_configuration.name, project_configuration.platform))
+ f' '
+ f'$(Configuration)\\$(Platform)\\'))
def _WriteOutIntDirPropertyGroups(self, project_configurations):
"""Writes the OutDir and IntDir property groups.
@@ -880,8 +885,8 @@ def _WriteOutIntDirPropertyGroups(self, project_configurations):
"""
self.WriteLines([
' ',
- ' <_ProjectFileVersion>{0:s}'.format(
- self._project_file_version)])
+ (f' <_ProjectFileVersion>{self._project_file_version:s}'
+ f'')])
# Mimic Visual Studio behavior and output the configurations
# in platforms by name.
@@ -894,10 +899,11 @@ def _WriteOutIntDirPropertyGroups(self, project_configurations):
if project_configuration.link_incremental != '':
self.WriteLine((
- ' {2:s}').format(
- project_configuration.name, project_configuration.platform,
- project_configuration.link_incremental_string))
+ f' '
+ f'{project_configuration.link_incremental_string:s}'
+ f''))
self.WriteLine(' ')
@@ -911,8 +917,7 @@ def _WriteResourceFiles(self, resource_files):
self.WriteLine(' ')
for filename in resource_files:
- self.WriteLine(' '.format(
- filename))
+ self.WriteLine(f' ')
self.WriteLine(' ')
@@ -926,7 +931,7 @@ def _WriteSourceFiles(self, source_files):
self.WriteLine(' ')
for filename in source_files:
- self.WriteLine(' '.format(filename))
+ self.WriteLine(f' ')
self.WriteLine(' ')
@@ -953,9 +958,9 @@ def WriteConfigurations(self, project_configurations):
# in reverse of name.
for project_configuration in project_configurations.GetSorted(reverse=True):
self.WriteLines([
- (' '.format(
- project_configuration.name, project_configuration.platform)),
+ (f' '),
(' '),
@@ -991,15 +996,13 @@ def WriteDependencies(self, dependencies, solution_projects_by_guid):
for dependency_name in sorted(dependencies_by_name):
dependency_project = dependencies_by_name[dependency_name]
- dependency_filename = '..\\{0:s}.vcxproj'.format(
- dependency_project.filename)
+ dependency_filename = f'..\\{dependency_project.filename:s}.vcxproj'
dependency_guid = dependency_project.guid.lower()
self.WriteLines([
- (' ').format(
- dependency_filename),
- ' {{{0:s}}}'.format(dependency_guid),
+ f' ',
+ f' {{{dependency_guid:s}}}',
' false',
' '])
@@ -1033,9 +1036,9 @@ def WriteHeader(self):
self.WriteLines([
'',
- ('').format(
- self._tools_version)])
+ (f'')])
def WriteProjectConfigurations(self, project_configurations):
"""Writes the project configurations.
@@ -1046,16 +1049,15 @@ def WriteProjectConfigurations(self, project_configurations):
self.WriteLine(' ')
for project_configuration in project_configurations.GetSorted():
- self.WriteLine(' '.format(
- project_configuration.name, project_configuration.platform))
-
- self.WriteLine(' {0:s}'.format(
- project_configuration.name))
-
- self.WriteLine(' {0:s}'.format(
- project_configuration.platform))
-
- self.WriteLine(' ')
+ self.WriteLines([
+ (f' '),
+ (f' {project_configuration.name:s}'
+ f''),
+ (f' {project_configuration.platform:s}'
+ f''),
+ ' '])
self.WriteLine(' ')
@@ -1065,17 +1067,14 @@ def WriteProjectInformation(self, project_information):
Args:
project_information (VSProjectInformation): project information.
"""
- self.WriteLine(' ')
-
- self.WriteLine(' {{{0:s}}}'.format(
- project_information.guid))
-
- self.WriteLine(' {0:s}'.format(
- project_information.root_name_space))
+ self.WriteLines([
+ ' ',
+ f' {{{project_information.guid:s}}}',
+ (f' {project_information.root_name_space:s}'
+ f'')])
if project_information.keyword:
- self.WriteLine(' {0:s}'.format(
- project_information.keyword))
+ self.WriteLine(' {project_information.keyword:s}')
self.WriteLine(' ')
@@ -1101,58 +1100,60 @@ def _WriteClCompileSection(self, project_configuration):
include_directories = re.sub(r'"', r'', include_directories)
if include_directories and include_directories[-1] != ';':
- include_directories = '{0:s};'.format(
- include_directories)
+ include_directories = ''.join([include_directories, ';'])
- include_directories = '{0:s}%(AdditionalIncludeDirectories)'.format(
- include_directories)
+ include_directories = ''.join([
+ include_directories, '%(AdditionalIncludeDirectories)'])
preprocessor_definitions = project_configuration.preprocessor_definitions
if preprocessor_definitions and preprocessor_definitions[-1] != ';':
- preprocessor_definitions = '{0:s};'.format(preprocessor_definitions)
+ preprocessor_definitions = ''.join([preprocessor_definitions, ';'])
- preprocessor_definitions = '{0:s}%(PreprocessorDefinitions)'.format(
- preprocessor_definitions)
+ preprocessor_definitions = ''.join([
+ preprocessor_definitions, '%(PreprocessorDefinitions)'])
self.WriteLine(' ')
if project_configuration.optimization != '':
- self.WriteLine(' {0:s}'.format(
- project_configuration.optimization_string))
+ self.WriteLine((
+ f' {project_configuration.optimization_string:s}'
+ f''))
if project_configuration.enable_intrinsic_functions != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.enable_intrinsic_functions))
+ f' '
+ f'{project_configuration.enable_intrinsic_functions:s}'
+ f''))
self.WriteLine((
- ' {0:s}'
- '').format(include_directories))
+ f' {include_directories:s}'
+ f''))
self.WriteLine((
- ' {0:s}'
- '').format(preprocessor_definitions))
+ f' {preprocessor_definitions:s}'
+ f''))
if project_configuration.basic_runtime_checks != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.basic_runtime_checks_string))
+ f' '
+ f'{project_configuration.basic_runtime_checks_string:s}'
+ f''))
if project_configuration.smaller_type_check != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.smaller_type_check))
+ f' '
+ f'{project_configuration.smaller_type_check:s}'))
self.WriteLine((
- ' {0:s}').format(
- project_configuration.runtime_librarian_string))
+ f' '
+ f'{project_configuration.runtime_librarian_string:s}'))
if project_configuration.enable_function_level_linking != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.enable_function_level_linking))
+ f' '
+ f'{project_configuration.enable_function_level_linking:s}'
+ f''))
if project_configuration.precompiled_header != '':
# A value of 0 is represented by an empty XML tag.
@@ -1160,17 +1161,18 @@ def _WriteClCompileSection(self, project_configuration):
self.WriteLine(' ')
else:
self.WriteLine((
- ' {0:s}').format(
- project_configuration.precompiled_header_string))
+ f' '
+ f'{project_configuration.precompiled_header_string:s}'
+ f''))
- self.WriteLine(' {0:s}'.format(
- project_configuration.warning_level_string))
+ self.WriteLine((
+ f' {project_configuration.warning_level_string:s}'
+ f''))
if project_configuration.warning_as_error:
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.warning_as_error))
+ f' '
+ f'{project_configuration.warning_as_error:s}'))
if project_configuration.debug_information_format != '':
# A value of 0 is represented by an empty XML tag.
@@ -1178,13 +1180,14 @@ def _WriteClCompileSection(self, project_configuration):
self.WriteLine(' ')
else:
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.debug_information_format_string))
+ f' '
+ f'{project_configuration.debug_information_format_string:s}'
+ f''))
if project_configuration.compile_as:
- self.WriteLine(' {0:s}'.format(
- project_configuration.compile_as_string))
+ self.WriteLine((
+ f' {project_configuration.compile_as_string:s}'
+ f''))
self.WriteLine(' ')
@@ -1196,26 +1199,28 @@ def _WriteConfigurationPropertyGroup(self, project_configuration):
"""
self._WriteConfigurationPropertyGroupHeader(project_configuration)
- self.WriteLine(' {0:s}'.format(
- project_configuration.output_type_string))
+ self.WriteLine((
+ f' {project_configuration.output_type_string:s}'
+ f''))
platform_toolset = project_configuration.GetPlatformToolset(self._version)
if platform_toolset:
- self.WriteLine(' {0:s}'.format(
- platform_toolset))
+ self.WriteLine(
+ f' {platform_toolset:s}')
if project_configuration.character_set:
- self.WriteLine(' {0:s}'.format(
- project_configuration.character_set_string))
+ self.WriteLine((
+ f' {project_configuration.character_set_string:s}'
+ f''))
if project_configuration.managed_extensions == '1':
self.WriteLine(' true')
if project_configuration.whole_program_optimization:
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.whole_program_optimization_string))
+ f' '
+ f'{project_configuration.whole_program_optimization_string:s}'
+ f''))
self._WriteConfigurationPropertyGroupFooter()
@@ -1254,21 +1259,21 @@ def _WriteLibrarianSection(self, project_configuration):
self.WriteLines([
' ',
- ' {0:s}'.format(librarian_output_file)])
+ f' {librarian_output_file:s}'])
if project_configuration.module_definition_file != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.module_definition_file))
+ f' '
+ f'{project_configuration.module_definition_file:s}'
+ f''))
else:
self.WriteLine(' ')
if project_configuration.librarian_ignore_defaults != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.librarian_ignore_defaults))
+ f' '
+ f'{project_configuration.librarian_ignore_defaults:s}'
+ f''))
self.WriteLine(' ')
@@ -1289,30 +1294,27 @@ def _WriteLinkerSection(self, project_configuration):
r'[$][(]OutDir[)]\\', r'$(OutDir)', additional_dependencies)
if additional_dependencies and additional_dependencies[-1] != ';':
- additional_dependencies = '{0:s};'.format(additional_dependencies)
+ additional_dependencies = ''.join([additional_dependencies, ';'])
- additional_dependencies = (
- '{0:s}%(AdditionalDependencies)').format(
- additional_dependencies)
+ additional_dependencies = ''.join([
+ additional_dependencies, '%(AdditionalDependencies)'])
self.WriteLine((
- ' {0:s}'
- '').format(
- additional_dependencies))
+ f' {additional_dependencies:s}'
+ f''))
if project_configuration.linker_output_file:
linker_output_file = re.sub(
r'[$][(]OutDir[)]\\', r'$(OutDir)',
project_configuration.linker_output_file)
- self.WriteLine(' {0:s}'.format(
- linker_output_file))
+ self.WriteLine(f' {linker_output_file:s}')
if project_configuration.module_definition_file != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.module_definition_file))
+ f' '
+ f'{project_configuration.module_definition_file:s}'
+ f''))
if project_configuration.library_directories:
library_directories = ';'.join(project_configuration.library_directories)
@@ -1321,48 +1323,49 @@ def _WriteLinkerSection(self, project_configuration):
library_directories = re.sub(r'"', r'', library_directories)
if library_directories and library_directories[-1] != ';':
- library_directories = '{0:s};'.format(library_directories)
+ library_directories = ''.join([library_directories, ';'])
- library_directories = (
- '{0:s}%(AdditionalLibraryDirectories)').format(
- library_directories)
+ library_directories = ''.join([
+ library_directories, '%(AdditionalLibraryDirectories)'])
self.WriteLine((
- ' {0:s}'
- '').format(
- library_directories))
+ f' {library_directories:s}'
+ f''))
if project_configuration.generate_debug_information != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.generate_debug_information))
+ f' '
+ f'{project_configuration.generate_debug_information:s}'
+ f''))
if project_configuration.sub_system != '':
- self.WriteLine(' {0:s}'.format(
- project_configuration.sub_system_string))
+ self.WriteLine((
+ f' {project_configuration.sub_system_string:s}'
+ f''))
if project_configuration.optimize_references == '0':
self.WriteLine(' ')
elif project_configuration.optimize_references != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.optimize_references_string))
+ f' '
+ f'{project_configuration.optimize_references_string:s}'
+ f''))
if project_configuration.enable_comdat_folding == '0':
self.WriteLine(' ')
elif project_configuration.enable_comdat_folding != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.enable_comdat_folding_string))
+ f' '
+ f'{project_configuration.enable_comdat_folding_string:s}'
+ f''))
if project_configuration.randomized_base_address != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.randomized_base_address_string))
+ f' '
+ f'{project_configuration.randomized_base_address_string:s}'
+ f''))
if project_configuration.fixed_base_address == '0':
# A value of 0 is represented by an empty XML tag.
@@ -1374,22 +1377,22 @@ def _WriteLinkerSection(self, project_configuration):
self.WriteLine(' ')
else:
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.data_execution_prevention_string))
+ f' '
+ f'{project_configuration.data_execution_prevention_string:s}'
+ f''))
if (project_configuration.target_machine != '' and
project_configuration.linker_values_set):
- self.WriteLine(' {0:s}'.format(
- project_configuration.target_machine_string))
+ self.WriteLine((
+ f' '
+ f'{project_configuration.target_machine_string:s}'))
if project_configuration.import_library:
import_library = re.sub(
r'[$][(]OutDir[)]\\', r'$(OutDir)',
project_configuration.import_library)
- self.WriteLine(' {0:s}'.format(
- import_library))
+ self.WriteLine(f' {import_library:s}')
self.WriteLine(' ')
@@ -1407,16 +1410,16 @@ def _WriteOutIntDirConditions(
if len(project_configurations.platforms) == 1:
self.WriteLines([
- (' ').format(
- project_configuration.name, project_configuration.platform),
+ (f' '),
' $(SolutionDir)$(Configuration)\\',
' $(Configuration)\\'])
else:
self.WriteLines([
- (' ').format(
- project_configuration.name, project_configuration.platform),
+ (f' '),
(' $(SolutionDir)$(Configuration)\\$(Platform)\\'
''),
' $(Configuration)\\$(Platform)\\'])
@@ -1434,8 +1437,8 @@ def _WriteOutIntDirPropertyGroups(self, project_configurations):
"""
self.WriteLines([
' ',
- ' <_ProjectFileVersion>{0:s}'.format(
- self._project_file_version),
+ (f' <_ProjectFileVersion>{self._project_file_version:s}'
+ f''),
' '])
# Mimic Visual Studio behavior and output the configurations
@@ -1449,11 +1452,11 @@ def _WriteOutIntDirPropertyGroups(self, project_configurations):
# if project_configuration.link_incremental != '':
# self.WriteLine((
- # ' {2:s}'
- # '').format(
- # project_configuration.name, project_configuration.platform,
- # project_configuration.link_incremental_string))
+ # f' '
+ # f'{project_configuration.link_incremental_string:s}'
+ # f''))
class VS2013ProjectFileWriter(VS2010ProjectFileWriter):
@@ -1491,16 +1494,16 @@ def _WriteOutIntDirConditions(
if len(project_configurations.platforms) == 1:
self.WriteLines([
- (' ').format(
- project_configuration.name, project_configuration.platform),
+ (f' '),
' $(SolutionDir)$(Configuration)\\',
' $(Configuration)\\'])
else:
self.WriteLines([
- (' ').format(
- project_configuration.name, project_configuration.platform),
+ (f' '),
(' $(SolutionDir)$(Configuration)\\$(Platform)\\'
''),
' $(Configuration)\\$(Platform)\\'])
@@ -1558,29 +1561,27 @@ def _WriteLinkerSection(self, project_configuration):
r'[$][(]OutDir[)]\\', r'$(OutDir)', additional_dependencies)
if additional_dependencies and additional_dependencies[-1] != ';':
- additional_dependencies = '{0:s};'.format(additional_dependencies)
+ additional_dependencies = ''.join([additional_dependencies, ';'])
- additional_dependencies = '{0:s}%(AdditionalDependencies)'.format(
- additional_dependencies)
+ additional_dependencies = ''.join([
+ additional_dependencies, '%(AdditionalDependencies)'])
self.WriteLine((
- ' {0:s}'
- '').format(
- additional_dependencies))
+ f' {additional_dependencies:s}'
+ f''))
if project_configuration.linker_output_file:
linker_output_file = re.sub(
r'[$][(]OutDir[)]\\', r'$(OutDir)',
project_configuration.linker_output_file)
- self.WriteLine(' {0:s}'.format(
- linker_output_file))
+ self.WriteLine(f' {linker_output_file:s}')
if project_configuration.module_definition_file != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.module_definition_file))
+ f' '
+ f'{project_configuration.module_definition_file:s}'
+ f''))
if project_configuration.library_directories:
library_directories = ';'.join(project_configuration.library_directories)
@@ -1589,25 +1590,25 @@ def _WriteLinkerSection(self, project_configuration):
library_directories = re.sub(r'"', r'', library_directories)
if library_directories and library_directories[-1] != ';':
- library_directories = '{0:s};'.format(library_directories)
+ library_directories = ''.join([library_directories, ';'])
- library_directories = '{0:s}%(AdditionalLibraryDirectories)'.format(
- library_directories)
+ library_directories = ''.join([
+ library_directories, '%(AdditionalLibraryDirectories)'])
self.WriteLine((
- ' {0:s}'
- '').format(
- library_directories))
+ f' {library_directories:s}'
+ f''))
if project_configuration.generate_debug_information != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.generate_debug_information))
+ f' '
+ f'{project_configuration.generate_debug_information:s}'
+ f''))
if project_configuration.sub_system != '':
- self.WriteLine(' {0:s}'.format(
- project_configuration.sub_system_string))
+ self.WriteLine((
+ f' {project_configuration.sub_system_string:s}'
+ f''))
if project_configuration.optimize_references == '0':
self.WriteLines([
@@ -1616,8 +1617,9 @@ def _WriteLinkerSection(self, project_configuration):
elif project_configuration.optimize_references != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.optimize_references_string))
+ f' '
+ f'{project_configuration.optimize_references_string:s}'
+ f''))
if project_configuration.enable_comdat_folding == '0':
self.WriteLines([
@@ -1626,14 +1628,15 @@ def _WriteLinkerSection(self, project_configuration):
elif project_configuration.enable_comdat_folding != '':
self.WriteLine((
- ' {0:s}').format(
- project_configuration.enable_comdat_folding_string))
+ f' '
+ f'{project_configuration.enable_comdat_folding_string:s}'
+ f''))
if project_configuration.randomized_base_address != '':
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.randomized_base_address_string))
+ f' '
+ f'{project_configuration.randomized_base_address_string:s}'
+ f''))
if project_configuration.fixed_base_address == '0':
self.WriteLines([
@@ -1648,21 +1651,21 @@ def _WriteLinkerSection(self, project_configuration):
' '])
else:
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.data_execution_prevention_string))
+ f' '
+ f'{project_configuration.data_execution_prevention_string:s}'
+ f''))
if project_configuration.import_library:
import_library = re.sub(
r'[$][(]OutDir[)]\\', r'$(OutDir)',
project_configuration.import_library)
- self.WriteLine(' {0:s}'.format(
- import_library))
+ self.WriteLine(f' {import_library:s}')
if project_configuration.target_machine != '':
- self.WriteLine(' {0:s}'.format(
- project_configuration.target_machine_string))
+ self.WriteLine((
+ f' '
+ f'{project_configuration.target_machine_string:s}'))
if project_configuration.output_type != definitions.OUTPUT_TYPE_APPLICATION:
self.WriteLine(
@@ -1684,16 +1687,16 @@ def _WriteOutIntDirConditions(
if len(project_configurations.platforms) == 1:
self.WriteLines([
- (' ').format(
- project_configuration.name, project_configuration.platform),
+ (f' '),
' $(SolutionDir)$(Configuration)\\',
' $(Configuration)\\'])
else:
self.WriteLines([
- (' ').format(
- project_configuration.name, project_configuration.platform),
+ (f' '),
(' $(SolutionDir)$(Configuration)\\$(Platform)\\'
''),
' $(Configuration)\\$(Platform)\\'])
@@ -1708,9 +1711,9 @@ def WriteHeader(self):
"""Writes a file header."""
self.WriteLines([
'',
- ('').format(
- self._tools_version)])
+ (f'')])
class VS2019ProjectFileWriter(VS2017ProjectFileWriter):
@@ -1742,28 +1745,30 @@ def _WriteConfigurationPropertyGroup(self, project_configuration):
"""
self._WriteConfigurationPropertyGroupHeader(project_configuration)
- self.WriteLine(' {0:s}'.format(
- project_configuration.output_type_string))
+ self.WriteLine((
+ f' {project_configuration.output_type_string:s}'
+ f''))
self.WriteLine(' v143')
if project_configuration.character_set:
- self.WriteLine(' {0:s}'.format(
- project_configuration.character_set_string))
+ self.WriteLine((
+ f' {project_configuration.character_set_string:s}'
+ f''))
if project_configuration.managed_extensions == '1':
self.WriteLine(' true')
if project_configuration.whole_program_optimization:
self.WriteLine((
- ' {0:s}'
- '').format(
- project_configuration.whole_program_optimization_string))
+ f' '
+ f'{project_configuration.whole_program_optimization_string:s}'
+ f''))
platform_toolset = project_configuration.GetPlatformToolset(self._version)
if platform_toolset:
- self.WriteLine(' {0:s}'.format(
- platform_toolset))
+ self.WriteLine(
+ f' {platform_toolset:s}')
self._WriteConfigurationPropertyGroupFooter()
@@ -1773,19 +1778,15 @@ def WriteProjectInformation(self, project_information):
Args:
project_information (VSProjectInformation): project information.
"""
- self.WriteLine(' ')
-
- self.WriteLine(' 17.0')
-
- self.WriteLine(' {{{0:s}}}'.format(
- project_information.guid))
-
- self.WriteLine(' {0:s}'.format(
- project_information.root_name_space))
+ self.WriteLines([
+ ' ',
+ ' 17.0',
+ f' {{{project_information.guid:s}}}',
+ (f' {project_information.root_name_space:s}'
+ f'')])
if project_information.keyword:
- self.WriteLine(' {0:s}'.format(
- project_information.keyword))
+ self.WriteLine(' {project_information.keyword:s}')
self.WriteLine(' ')
@@ -1811,14 +1812,14 @@ def _WriteProjectConfigurationPlatforms(
configuration = solution_configurations.GetByIdentifier(
configuration_name, configuration_platform)
- self.WriteLine((
- '\t\t{{{0:s}}}.{1:s}|{2:s}.ActiveCfg = {1:s}|{2:s}').format(
- solution_project.guid.upper(), configuration.name,
- configuration.platform))
- self.WriteLine((
- '\t\t{{{0:s}}}.{1:s}|{2:s}.Build.0 = {1:s}|{2:s}').format(
- solution_project.guid.upper(), configuration.name,
- configuration.platform))
+ solution_project_guid = solution_project.guid.upper()
+ self.WriteLines([
+ (f'\t\t{{{solution_project_guid:s}}}.{configuration.name:s}|'
+ f'{configuration.platform:s}.ActiveCfg = '
+ f'{configuration.name:s}|{configuration.platform:s}'),
+ (f'\t\t{{{solution_project_guid:s}}}.{configuration.name:s}|'
+ f'{configuration.platform:s}.Build.0 = {configuration.name:s}|'
+ f'{configuration.platform:s}')])
self.WriteLine('\tEndGlobalSection')
@@ -1840,8 +1841,9 @@ def _WriteSolutionConfigurationPlatforms(
configuration = solution_configurations.GetByIdentifier(
configuration_name, configuration_platform)
- self.WriteLine('\t\t{0:s}|{1:s} = {0:s}|{1:s}'.format(
- configuration.name, configuration.platform))
+ self.WriteLine((
+ f'\t\t{configuration.name:s}|{configuration.platform:s} = '
+ f'{configuration.name:s}|{configuration.platform:s}'))
self.WriteLine('\tEndGlobalSection')
@@ -1909,14 +1911,11 @@ def WriteProject(self, solution_project):
Args:
solution_project (VSSolutionProject): project.
"""
- solution_project_filename = '{0:s}.vcproj'.format(
- solution_project.filename)
-
+ solution_project_guid = solution_project.guid.upper()
self.WriteLine((
- 'Project("{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}") = "{0:s}", '
- '"{1:s}", "{{{2:s}}}"').format(
- solution_project.name, solution_project_filename,
- solution_project.guid.upper()))
+ f'Project("{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}") = '
+ f'"{solution_project.name:s}", "{solution_project.filename:s}.vcproj", '
+ f'"{{{solution_project_guid:s}}}"'))
if solution_project.dependencies:
self.WriteLine(
@@ -1969,16 +1968,13 @@ def WriteProject(self, solution_project):
Args:
solution_project (VSSolutionProject): project.
"""
- solution_project_filename = '{0:s}.vcxproj'.format(
- solution_project.filename)
-
- self.WriteLine((
- 'Project("{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}") = "{0:s}", '
- '"{1:s}", "{{{2:s}}}"').format(
- solution_project.name, solution_project_filename,
- solution_project.guid.upper()))
-
- self.WriteLine('EndProject')
+ solution_project_guid = solution_project.guid.upper()
+ self.WriteLines([
+ (f'Project("{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}") = '
+ f'"{solution_project.name:s}", '
+ f'"{solution_project.filename:s}.vcxproj", '
+ f'"{{{solution_project_guid:s}}}"'),
+ 'EndProject'])
class VS2012SolutionFileWriter(VS2010SolutionFileWriter):
@@ -1997,14 +1993,12 @@ def WriteProject(self, solution_project):
Args:
solution_project (VSSolutionProject): project.
"""
- solution_project_filename = '{0:s}.vcxproj'.format(
- solution_project.filename)
-
+ solution_project_guid = solution_project.guid.upper()
self.WriteLine((
- 'Project("{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}") = "{0:s}", '
- '"{1:s}", "{{{2:s}}}"').format(
- solution_project.name, solution_project_filename,
- solution_project.guid.upper()))
+ f'Project("{{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}}") = '
+ f'"{solution_project.name:s}", '
+ f'"{solution_project.filename:s}.vcxproj", '
+ f'"{{{solution_project_guid:s}}}"'))
# TODO: what about:
# '\tProjectSection(ProjectDependencies) = postProject'