Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 from __future__ import print_function
00038
00039 import subprocess
00040
00041 cmd = "find . -type f ! -name '*.svn-base' -a ! -name '*.hg' -a ! -name '*.git' -a " \
00042 "\( -name '*.c*' -o -name '*.h*' \)"
00043
00044 header_mappings = {
00045 'pluginlib/class_desc.h': 'pluginlib/class_desc.hpp',
00046 'pluginlib/class_list_macros.h': 'pluginlib/class_list_macros.hpp',
00047 'pluginlib/class_loader_base.h': 'pluginlib/class_loader_base.hpp',
00048 'pluginlib/class_loader.h': 'pluginlib/class_loader.hpp',
00049 'pluginlib/class_loader_imp.h': 'pluginlib/class_loader_imp.hpp',
00050 'pluginlib/pluginlib_exceptions.h': 'pluginlib/exceptions.hpp',
00051 }
00052 include_tokens = {
00053 '"': '"',
00054 '<': '>',
00055 }
00056 include_prefix = '#include '
00057 sed_cmd_prefix = ' -exec sed -i \' s'
00058 sed_cmd_suffix = ' {} \; '
00059 sed_separator = '@'
00060 full_cmd = cmd
00061 for old_header, new_header in header_mappings.iteritems():
00062 for leading_token, ending_token in include_tokens.iteritems():
00063 full_cmd += \
00064 sed_cmd_prefix + sed_separator + \
00065 include_prefix + leading_token + old_header + ending_token + sed_separator + \
00066 include_prefix + leading_token + new_header + ending_token + sed_separator + \
00067 "g'" + sed_cmd_suffix
00068 print("Looking for '%s' to replace with '%s'" % (old_header, new_header))
00069
00070 print('Running %s' % full_cmd)
00071 ret_code = subprocess.call(full_cmd, shell=True)
00072 if ret_code == 0:
00073 print('success')
00074 else:
00075 print('failure')