class_loader_headers_update.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # Software License Agreement (BSD License)
00003 #
00004 # Copyright (c) 2018, Open Source Robotics Foundation, Inc.
00005 # All rights reserved.
00006 #
00007 # Redistribution and use in source and binary forms, with or without
00008 # modification, are permitted provided that the following conditions
00009 # are met:
00010 #
00011 #  * Redistributions of source code must retain the above copyright
00012 #    notice, this list of conditions and the following disclaimer.
00013 #  * Redistributions in binary form must reproduce the above
00014 #    copyright notice, this list of conditions and the following
00015 #    disclaimer in the documentation and/or other materials provided
00016 #    with the distribution.
00017 #  * Neither the name of the copyright holders nor the names of its
00018 #    contributors may be used to endorse or promote products derived
00019 #    from this software without specific prior written permission.
00020 #
00021 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 # POSSIBILITY OF SUCH DAMAGE.
00033 
00034 # Run this script to update legacy pluginlib macros to utilize new
00035 # simplified PLUGINLIB_EXPORT_CLASS macro.
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     'class_loader/class_loader.h': 'class_loader/class_loader.hpp',
00046     'class_loader/class_loader_core.h': 'class_loader/class_loader_core.hpp',
00047     'class_loader/class_loader_exceptions.h': 'class_loader/exceptions.hpp',
00048     'class_loader/class_loader_register_macro.h': 'class_loader/register_macro.hpp',
00049     'class_loader/meta_object.h': 'class_loader/meta_object.hpp',
00050     'class_loader/multi_library_class_loader.h': 'class_loader/multi_library_class_loader.hpp',
00051     'class_loader/console_bridge_compatibility.h': 'class_loader/console_bridge_compatibility.hpp',
00052 }
00053 include_tokens = {
00054     '"': '"',
00055     '<': '>',
00056 }
00057 include_prefix = '#include '
00058 sed_cmd_prefix = ' -exec sed -i \' s'
00059 sed_cmd_suffix = ' {} \; '
00060 sed_separator = '@'
00061 full_cmd = cmd
00062 for old_header, new_header in header_mappings.iteritems():
00063     for leading_token, ending_token in include_tokens.iteritems():
00064         full_cmd += \
00065             sed_cmd_prefix + sed_separator + \
00066             include_prefix + leading_token + old_header + ending_token + sed_separator + \
00067             include_prefix + leading_token + new_header + ending_token + sed_separator + \
00068             "g'" + sed_cmd_suffix
00069     print("Looking for '%s' to replace with '%s'" % (old_header, new_header))
00070 
00071 print('Running %s' % full_cmd)
00072 ret_code = subprocess.call(full_cmd, shell=True)
00073 if ret_code == 0:
00074     print('success')
00075 else:
00076     print('failure')


class_loader
Author(s): Mirza Shah
autogenerated on Thu Jun 6 2019 20:43:27