Skip to content

Commit

Permalink
Changes to use f-strings instead of format
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jun 4, 2024
1 parent 99f4fb8 commit dd98a59
Show file tree
Hide file tree
Showing 5 changed files with 331 additions and 338 deletions.
2 changes: 1 addition & 1 deletion scripts/msvscpp-convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 2 additions & 3 deletions vstools/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
26 changes: 13 additions & 13 deletions vstools/solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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)

Expand All @@ -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'
Expand Down
Loading

0 comments on commit dd98a59

Please sign in to comment.