create.py
Go to the documentation of this file.
1 
2 import os
3 import shutil
4 from utils import author_name
5 from utils import read_template
6 from utils import instantiate_template
7 
8 ##############################################################################
9 # Template
10 ##############################################################################
11 
12 def get_qt_text_templates(package, type):
13  template_dir = os.path.join(os.path.dirname(__file__),'templates',type)
14  templates = {}
15  templates['mainpage.dox'] = read_template(os.path.join(template_dir,'mainpage.dox'))
16  templates['CMakeLists.txt'] = read_template(os.path.join(template_dir,'CMakeLists.txt'))
17  templates['package.xml'] = read_template(os.path.join(template_dir,'package.xml'))
18  templates[os.path.join('ui','main_window.ui')] = read_template(os.path.join(template_dir,'ui','main_window.ui'))
19  templates[os.path.join('src','main.cpp')] = read_template(os.path.join(template_dir,'src','main.cpp'))
20  templates[os.path.join('src','main_window.cpp')] = read_template(os.path.join(template_dir,'src','main_window.cpp'))
21  templates[os.path.join('src','qnode.cpp')] = read_template(os.path.join(template_dir,'src','qnode.cpp'))
22  templates[os.path.join('resources','images.qrc')] = read_template(os.path.join(template_dir,'resources','images.qrc'))
23  templates[os.path.join('include',package,'main_window.hpp')] = read_template(os.path.join(template_dir,'include','PACKAGE_NAME','main_window.hpp'))
24  templates[os.path.join('include',package,'qnode.hpp')] = read_template(os.path.join(template_dir,'include','PACKAGE_NAME','qnode.hpp'))
25  return templates
26 
27 def create_qt_ros_package(package, depends, type):
28 
29  p = os.path.abspath(package)
30  os.makedirs(os.path.join(p,"src"))
31  os.makedirs(os.path.join(p,"include"))
32  os.makedirs(os.path.join(p,"include",package))
33  os.makedirs(os.path.join(p,"resources"))
34  os.makedirs(os.path.join(p,"resources","images"))
35  os.makedirs(os.path.join(p,"ui"))
36  print "Created qt package directories."
37 
38  # Qt text files
39  templates = get_qt_text_templates(package, type)
40  for filename, template in templates.iteritems():
41  contents = instantiate_template(template, package, package, author_name(), depends)
42  try:
43  p = os.path.abspath(os.path.join(package, filename))
44  f = open(p, 'w')
45  f.write(contents)
46  print "Created package file", p
47  finally:
48  f.close()
49  # Qt binary files
50  template_dir = os.path.join(os.path.dirname(__file__),'templates',type)
51  shutil.copy(os.path.join(template_dir,'resources','images','icon.png'),
52  os.path.join(os.path.abspath(package),'resources','images','icon.png'))
53 
54 def create_qt_ros_catkin_package(package, depends):
55  create_qt_ros_package(package, depends, 'qt-ros')
def read_template(tmplf)
Definition: utils.py:29
def create_qt_ros_catkin_package(package, depends)
Definition: create.py:54
def author_name()
Utilities.
Definition: utils.py:5
def instantiate_template(template, package, description, author, depends)
Definition: utils.py:39
def get_qt_text_templates(package, type)
Template.
Definition: create.py:12
def create_qt_ros_package(package, depends, type)
Definition: create.py:27


qt_create
Author(s): Daniel Stonier
autogenerated on Wed Mar 11 2020 03:12:19