Skip to content

Commit

Permalink
common: removed unnecessary token numbers at string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelliavonau committed Dec 10, 2019
1 parent d8ed7d2 commit f479c1d
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 68 deletions.
2 changes: 1 addition & 1 deletion cmake_converter/context_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, context, vs_project, cmake_lists_destination_path):
self.init_files(context, vs_project, cmake_lists_destination_path)
message(
context,
'Initialization data for conversion of project {0}'.format(context.vcxproj_path),
'Initialization data for conversion of project {}'.format(context.vcxproj_path),
''
)
for sln_config in context.sln_configurations_map:
Expand Down
26 changes: 13 additions & 13 deletions cmake_converter/data_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ def convert_project(self, context, xml_project_path, cmake_lists_destination_pat
"""
# Initialize Context of DataConverter
if not context.init(xml_project_path, cmake_lists_destination_path):
message(context, 'Unknown project type at {0}'.format(xml_project_path), 'error')
message(context, 'Unknown project type at {}'.format(xml_project_path), 'error')
return False

message(context, 'Conversion started: Project {0}'.format(context.project_name), 'done')
message(context, 'Collecting data for project {0}'.format(context.vcxproj_path), '')
message(context, 'Conversion started: Project {}'.format(context.project_name), 'done')
message(context, 'Collecting data for project {}'.format(context.vcxproj_path), '')
self.collect_data(context)
self.verify_data(context)
self.merge_data_settings(context)
Expand All @@ -252,7 +252,7 @@ def convert_project(self, context, xml_project_path, cmake_lists_destination_pat
cmake_file.write('\n' * 26)
else:
cmake_file = get_cmake_lists(context, context.cmake)
message(context, 'Writing data for project {0}'.format(context.vcxproj_path), '')
message(context, 'Writing data for project {}'.format(context.vcxproj_path), '')
self.write_data(context, cmake_file)
cmake_file.close()
warnings = ''
Expand Down Expand Up @@ -393,11 +393,11 @@ def __write_supported_architectures_check(context, cmake_file):
first = True
for arch in arch_list:
if first:
cmake_file.write('\"${{CMAKE_VS_PLATFORM_NAME}}\" STREQUAL \"{0}\"'
cmake_file.write('\"${{CMAKE_VS_PLATFORM_NAME}}\" STREQUAL \"{}\"'
.format(arch))
first = False
else:
cmake_file.write('\n OR \"${{CMAKE_VS_PLATFORM_NAME}}\" STREQUAL \"{0}\"'
cmake_file.write('\n OR \"${{CMAKE_VS_PLATFORM_NAME}}\" STREQUAL \"{}\"'
.format(arch))
cmake_file.write('))\n')
cmake_file.write(
Expand All @@ -418,7 +418,7 @@ def __write_global_configuration_types(root_cmake, configuration_types_list):
write_comment(root_cmake, 'Global configuration types')
root_cmake.write('set(CMAKE_CONFIGURATION_TYPES\n')
for configuration_type in configuration_types_list:
root_cmake.write(' \"{0}\"\n'.format(configuration_type))
root_cmake.write(' \"{}\"\n'.format(configuration_type))
root_cmake.write(' CACHE STRING "" FORCE\n)\n\n')

def __write_global_compile_options(self, root_context, root_cmake, configuration_types_list):
Expand Down Expand Up @@ -462,16 +462,16 @@ def __write_global_link_options(root_cmake, configuration_types_list):
for configuration_type in configuration_types_list:
ct_upper = configuration_type.upper()
root_cmake.write(
' set(CMAKE_EXE_LINKER_FLAGS_{0} \"${{CMAKE_EXE_LINKER_FLAGS}}\")\n'
' set(CMAKE_EXE_LINKER_FLAGS_{} \"${{CMAKE_EXE_LINKER_FLAGS}}\")\n'
.format(ct_upper))
root_cmake.write(
' set(CMAKE_MODULE_LINKER_FLAGS_{0} \"${{CMAKE_MODULE_LINKER_FLAGS}}\")\n'
' set(CMAKE_MODULE_LINKER_FLAGS_{} \"${{CMAKE_MODULE_LINKER_FLAGS}}\")\n'
.format(ct_upper))
root_cmake.write(
' set(CMAKE_SHARED_LINKER_FLAGS_{0} \"${{CMAKE_SHARED_LINKER_FLAGS}}\")\n'
' set(CMAKE_SHARED_LINKER_FLAGS_{} \"${{CMAKE_SHARED_LINKER_FLAGS}}\")\n'
.format(ct_upper))
root_cmake.write(
' set(CMAKE_STATIC_LINKER_FLAGS_{0} \"${{CMAKE_STATIC_LINKER_FLAGS}}\")\n'
' set(CMAKE_STATIC_LINKER_FLAGS_{} \"${{CMAKE_STATIC_LINKER_FLAGS}}\")\n'
.format(ct_upper))
root_cmake.write('endif()\n\n')

Expand All @@ -483,8 +483,8 @@ def __write_subdirectories(root_cmake, subdirectories_set, subdirectories_to_pro
for subdirectory in subdirectories:
binary_dir = ''
if '.' in subdirectory[:1]:
binary_dir = ' ${{CMAKE_BINARY_DIR}}/{0}'.format(
binary_dir = ' ${{CMAKE_BINARY_DIR}}/{}'.format(
subdirectories_to_project_name[subdirectory])
root_cmake.write('add_subdirectory({0}{1})\n'.format(
root_cmake.write('add_subdirectory({}{})\n'.format(
set_unix_slash(subdirectory), binary_dir))
root_cmake.write('\n')
8 changes: 4 additions & 4 deletions cmake_converter/data_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def search_file_path(context, xml_file):
if found_xml_file is None:
message(
context,
'{0} file not exists. '.format(xml_file),
'{} file not exists. '.format(xml_file),
'error'
)
return None

if found_xml_file != xml_file:
message(
context,
'file reference probably has wrong case {0}'.format(xml_file),
'file reference probably has wrong case {}'.format(xml_file),
'warn4'
)

Expand Down Expand Up @@ -171,7 +171,7 @@ def get_propertygroup(target_platform, attributes=''):
"""

prop = \
'//ns:PropertyGroup[@Condition="\'$(Configuration)|$(Platform)\'==\'{0}\'"{1}]'.format(
'//ns:PropertyGroup[@Condition="\'$(Configuration)|$(Platform)\'==\'{}\'"{}]'.format(
'|'.join(target_platform), attributes)

return prop
Expand All @@ -189,7 +189,7 @@ def get_definitiongroup(target_platform):

item = \
'//ns:ItemDefinitionGroup[@Condition="\'$(Configuration)|' \
'$(Platform)\'==\'{0}\'"]'.format('|'.join(target_platform))
'$(Platform)\'==\'{}\'"]'.format('|'.join(target_platform))

return item

Expand Down
22 changes: 11 additions & 11 deletions cmake_converter/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def set_additional_include_directories(aid_text, setting, context):
if inc_dirs:
message(
context,
'Include Directories : {0}'.format(context.settings[setting]['inc_dirs']),
'Include Directories : {}'.format(context.settings[setting]['inc_dirs']),
'')

@staticmethod
Expand Down Expand Up @@ -158,7 +158,7 @@ def write_target_references(context, cmake_file):
if deps_to_write:
cmake_file.write('add_dependencies(${PROJECT_NAME}\n')
for dep in deps_to_write:
cmake_file.write(' {0}\n'.format(dep))
cmake_file.write(' {}\n'.format(dep))
cmake_file.write(')\n\n')

@staticmethod
Expand All @@ -177,7 +177,7 @@ def write_link_dependencies(context, cmake_file):
cmake_file.write('target_link_libraries(${PROJECT_NAME} PUBLIC\n')
for reference in context.target_references:
cmake_file.write(' {}\n'.format(reference))
msg = 'External library found : {0}'.format(reference)
msg = 'External library found : {}'.format(reference)
message(context, msg, '')
cmake_file.write(')\n\n')

Expand Down Expand Up @@ -274,7 +274,7 @@ def write_target_dependency_packages(context, cmake_file):

for package in context.packages:
for package_property in package[2]:
id_version = '{0}.{1}'.format(package[0], package[1])
id_version = '{}.{}'.format(package[0], package[1])
for setting in context.settings:
if 'packages' not in context.settings[setting]:
continue
Expand All @@ -289,17 +289,17 @@ def write_target_dependency_packages(context, cmake_file):
has_written = write_property_of_settings(
cmake_file, context.settings,
context.sln_configurations_map,
begin_text='string(CONCAT "{0}"'.format(package_property_variable),
begin_text='string(CONCAT "{}"'.format(package_property_variable),
end_text=')',
property_name=id_version + package_property,
)
if has_written:
cmake_file.write(
'set_target_properties(${{PROJECT_NAME}} PROPERTIES "{0}" ${{{1}}})\n'
'set_target_properties(${{PROJECT_NAME}} PROPERTIES "{}" ${{{}}})\n'
.format(package_property, package_property_variable)
)
cmake_file.write(
'use_package(${{PROJECT_NAME}} {0} {1})\n'.format(package[0], package[1])
'use_package(${{PROJECT_NAME}} {} {})\n'.format(package[0], package[1])
)

@staticmethod
Expand All @@ -323,7 +323,7 @@ def __write_target_build_events(context, cmake_file, comment, value_name, event_
cmake_file, context.settings, context.sln_configurations_map,
begin_text='add_custom_command_if(\n'
' TARGET ${{PROJECT_NAME}}\n'
' {0}\n'
' {}\n'
' COMMANDS'.format(event_type),
end_text=')',
property_name=value_name,
Expand Down Expand Up @@ -371,10 +371,10 @@ def __write_file_custom_build_events(context, cmake_file, comment, value_name, e
text = write_property_of_settings(
cmake_file, file_context.settings, context.sln_configurations_map,
begin_text='add_custom_command_if(\n'
' OUTPUT "{0}"\n'
' OUTPUT "{}"\n'
' COMMANDS'.format(outputs),
end_text=' DEPENDS "{0}"\n'
' COMMENT "{1}"\n)'.format(file, description),
end_text=' DEPENDS "{}"\n'
' COMMENT "{}"\n)'.format(file, description),
property_name='file_custom_build_events',
write_setting_property_func=Dependencies.write_file_build_event_of_setting
)
Expand Down
12 changes: 6 additions & 6 deletions cmake_converter/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __write_defines_for_files(cmake_file,
config = config.replace('>', '')

cmake_file.write(
'{0} COMPILE_DEFINITIONS{1} "{2}"\n'
'{} COMPILE_DEFINITIONS{} "{}"\n'
.format(property_indent, config.upper(), ';'.join(property_value))
)

Expand All @@ -78,7 +78,7 @@ def write_defines(self, context, cmake_file):
cmake_file,
context.file_contexts[file].settings,
context.sln_configurations_map,
begin_text='set_source_files_properties({0} PROPERTIES'.format(file),
begin_text='set_source_files_properties({} PROPERTIES'.format(file),
end_text=')',
property_name=defines,
write_setting_property_func=self.__write_defines_for_files
Expand All @@ -100,15 +100,15 @@ def __write_compile_flags(context, cmake_file, compiler_flags_key):
text = write_property_of_settings(
cmake_file, context.file_contexts[file].settings,
context.sln_configurations_map,
begin_text='string(CONCAT {0}'.format(file_cl_var),
begin_text='string(CONCAT {}'.format(file_cl_var),
end_text=')',
property_name=compiler_flags_key,
indent=' ',
in_quotes=True
)
if text:
cmake_file.write(
' source_file_compile_options({0} ${{{1}}})\n'
' source_file_compile_options({} ${{{}}})\n'
.format(file, file_cl_var))

@staticmethod
Expand Down Expand Up @@ -138,8 +138,8 @@ def write_compile_and_link_flags(context, cmake_file, **kwargs):

and_os_str = ''
if os_check_str:
and_os_str = ' AND {0}'.format(os_check_str)
cmake_file.write('if({0}{1})\n'.format(compiler_check_str, and_os_str))
and_os_str = ' AND {}'.format(os_check_str)
cmake_file.write('if({}{})\n'.format(compiler_check_str, and_os_str))

Flags.__write_compile_flags(context, cmake_file, compiler_flags_key)
Flags.__write_link_flags(context, cmake_file, linker_flags_key)
Expand Down
4 changes: 2 additions & 2 deletions cmake_converter/project_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def apply_files_to_context(self, context):
has_headers = bool(context.headers)
context.has_headers = has_headers
context.has_only_headers = bool(has_headers and not context.sources)
message(context, "Source files extensions found: {0}".format(self.languages), 'INFO')
message(context, "Source files extensions found: {}".format(self.languages), 'INFO')

def find_cmake_project_languages(self, context):
"""
Expand Down Expand Up @@ -197,7 +197,7 @@ def write_cmake_project(context, cmake_file):
'error'
)
cmake_file.write(
'project({0}{1})\n\n'.format(make_cmake_literal(context, context.project_name), lang)
'project({}{})\n\n'.format(make_cmake_literal(context, context.project_name), lang)
)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion cmake_converter/project_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def set_output_dir_impl(context, output_node_text):
output_path = output_path.strip().replace('\n', '')
output_path = check_for_relative_in_path(context, output_path)
context.settings[context.current_setting]['OUTPUT_DIRECTORY'] = [output_path]
message(context, 'Output Dir = {0}'.format(output_path), '')
message(context, 'Output Dir = {}'.format(output_path), '')

@staticmethod
def set_output_file_impl(context, output_file_node_text):
Expand Down
Loading

0 comments on commit f479c1d

Please sign in to comment.