Go to the documentation of this file.00001
00002 import os
00003 import sys
00004 import shutil
00005 import utils
00006
00007 def get_templates(package):
00008 template_dir = os.path.join(os.path.dirname(__file__),'templates', 'comms')
00009 templates = {}
00010 templates['mainpage.dox'] = utils.read_template(os.path.join(template_dir,'mainpage.dox'))
00011 templates['CMakeLists.txt'] = utils.read_template(os.path.join(template_dir,'CMakeLists.txt'))
00012 templates['package.xml'] = utils.read_template(os.path.join(template_dir,'package.xml'))
00013 templates[os.path.join('msg','Dude.msg')] = utils.read_template(os.path.join(template_dir,'msg','Dude.msg'))
00014 templates[os.path.join('srv','HelloDude.srv')] = utils.read_template(os.path.join(template_dir,'srv','HelloDude.srv'))
00015 return templates
00016
00017 def create_package_directory(package):
00018 p = os.path.abspath(package)
00019 os.makedirs(p)
00020 print("Created package directory " + p)
00021 os.makedirs(os.path.join(p,"msg"))
00022 print("Created package directory " + os.path.join(p,"msg"))
00023 os.makedirs(os.path.join(p,"srv"))
00024 print("Created package directory " + os.path.join(p,"srv"))
00025
00026 def create_winros_catkin_package():
00027 (package, depends) = utils.parse_arguments(['std_msgs'])
00028 create_package_directory(package)
00029 templates = get_templates(package)
00030 package_depends = ''.join([' <depend package="%s"/>\n'%d for d in depends])
00031 cmake_depends = ''.join(['%s '%d for d in depends])
00032 for filename, template in templates.iteritems():
00033 contents = utils.instantiate_template(template, package, package, utils.author_name(), package_depends, cmake_depends)
00034 try:
00035 p = os.path.abspath(os.path.join(package, filename))
00036 f = open(p, 'w')
00037 f.write(contents.encode('utf-8'))
00038 print "Created package file", p
00039 finally:
00040 f.close()
00041 print "\nPlease edit package.xml, mainpage.dox, CMakeLists.txt, and add the package subdirectory."