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['Makefile'] = read_template(os.path.join(template_dir,'Makefile'))
00017     templates['CMakeLists.txt'] = read_template(os.path.join(template_dir,'CMakeLists.txt'))
00018     templates['manifest.xml'] = read_template(os.path.join(template_dir,'manifest.xml'))
00019     templates[os.path.join('ui','main_window.ui')] = read_template(os.path.join(template_dir,'ui','main_window.ui'))
00020     templates[os.path.join('src','main.cpp')] = read_template(os.path.join(template_dir,'src','main.cpp'))
00021     templates[os.path.join('src','main_window.cpp')] = read_template(os.path.join(template_dir,'src','main_window.cpp'))
00022     templates[os.path.join('src','qnode.cpp')] = read_template(os.path.join(template_dir,'src','qnode.cpp'))
00023     templates[os.path.join('resources','images.qrc')] = read_template(os.path.join(template_dir,'resources','images.qrc'))
00024     templates[os.path.join('include',package,'main_window.hpp')] = read_template(os.path.join(template_dir,'include','PACKAGE_NAME','main_window.hpp'))
00025     templates[os.path.join('include',package,'qnode.hpp')] = read_template(os.path.join(template_dir,'include','PACKAGE_NAME','qnode.hpp'))
00026     return templates
00027 
00028 def create_qt_ros_package(package, depends, type):
00029     
00030     p = os.path.abspath(package)
00031     os.makedirs(os.path.join(p,"src"))
00032     os.makedirs(os.path.join(p,"include"))
00033     os.makedirs(os.path.join(p,"include",package))
00034     os.makedirs(os.path.join(p,"resources"))
00035     os.makedirs(os.path.join(p,"resources","images"))
00036     os.makedirs(os.path.join(p,"ui"))
00037     print "Created qt package directories."
00038 
00039     # Qt text files
00040     templates = get_qt_text_templates(package, type)
00041     for filename, template in templates.iteritems():
00042         contents = instantiate_template(template, package, package, package, author_name(), depends)
00043         try:
00044             p = os.path.abspath(os.path.join(package, filename))
00045             f = open(p, 'w')
00046             f.write(contents)
00047             print "Created package file", p
00048         finally:
00049             f.close()
00050     # Qt binary files
00051     template_dir = os.path.join(os.path.dirname(__file__),'templates',type) 
00052     shutil.copy(os.path.join(template_dir,'resources','images','icon.png'),
00053                 os.path.join(os.path.abspath(package),'resources','images','icon.png'))
00054     
00055 def create_qt_ros_catkin_package(package, depends):
00056     create_qt_ros_package(package, depends, 'qt-ros')
00057 
00058 def create_qt_ros_legacy_package(package, depends):
00059     create_qt_ros_package(package, depends, 'qt-ros-legacy')


qt_create
Author(s): Daniel Stonier
autogenerated on Tue Jan 7 2014 11:33:54