create.py
Go to the documentation of this file.
00001 
00002 import os
00003 import shutil
00004 from utils import author_name
00005 from utils import read_template
00006 from utils import instantiate_template
00007 
00008 ##############################################################################
00009 # Template
00010 ##############################################################################
00011 
00012 def get_qt_text_templates(package, type):
00013     template_dir = os.path.join(os.path.dirname(__file__),'templates',type) 
00014     templates = {}
00015     templates['mainpage.dox'] = read_template(os.path.join(template_dir,'mainpage.dox'))
00016     templates['CMakeLists.txt'] = read_template(os.path.join(template_dir,'CMakeLists.txt'))
00017     templates['package.xml'] = read_template(os.path.join(template_dir,'package.xml'))
00018     templates[os.path.join('ui','main_window.ui')] = read_template(os.path.join(template_dir,'ui','main_window.ui'))
00019     templates[os.path.join('src','main.cpp')] = read_template(os.path.join(template_dir,'src','main.cpp'))
00020     templates[os.path.join('src','main_window.cpp')] = read_template(os.path.join(template_dir,'src','main_window.cpp'))
00021     templates[os.path.join('src','qnode.cpp')] = read_template(os.path.join(template_dir,'src','qnode.cpp'))
00022     templates[os.path.join('resources','images.qrc')] = read_template(os.path.join(template_dir,'resources','images.qrc'))
00023     templates[os.path.join('include',package,'main_window.hpp')] = read_template(os.path.join(template_dir,'include','PACKAGE_NAME','main_window.hpp'))
00024     templates[os.path.join('include',package,'qnode.hpp')] = read_template(os.path.join(template_dir,'include','PACKAGE_NAME','qnode.hpp'))
00025     return templates
00026 
00027 def create_qt_ros_package(package, depends, type):
00028     
00029     p = os.path.abspath(package)
00030     os.makedirs(os.path.join(p,"src"))
00031     os.makedirs(os.path.join(p,"include"))
00032     os.makedirs(os.path.join(p,"include",package))
00033     os.makedirs(os.path.join(p,"resources"))
00034     os.makedirs(os.path.join(p,"resources","images"))
00035     os.makedirs(os.path.join(p,"ui"))
00036     print "Created qt package directories."
00037 
00038     # Qt text files
00039     templates = get_qt_text_templates(package, type)
00040     for filename, template in templates.iteritems():
00041         contents = instantiate_template(template, package, package, author_name(), depends)
00042         try:
00043             p = os.path.abspath(os.path.join(package, filename))
00044             f = open(p, 'w')
00045             f.write(contents)
00046             print "Created package file", p
00047         finally:
00048             f.close()
00049     # Qt binary files
00050     template_dir = os.path.join(os.path.dirname(__file__),'templates',type) 
00051     shutil.copy(os.path.join(template_dir,'resources','images','icon.png'),
00052                 os.path.join(os.path.abspath(package),'resources','images','icon.png'))
00053     
00054 def create_qt_ros_catkin_package(package, depends):
00055     create_qt_ros_package(package, depends, 'qt-ros')


qt_create
Author(s): Daniel Stonier
autogenerated on Fri Aug 28 2015 12:16:18