2
# -*- coding: utf-8 -*-
3
# Copyright 2009 Canonical Ltd.
4
# Author 2009 Didier Roche
6
# This file is part of Quickly ubuntu-project-template
8
#This program is free software: you can redistribute it and/or modify it
9
#under the terms of the GNU General Public License version 3, as published
10
#by the Free Software Foundation.
12
#This program is distributed in the hope that it will be useful, but
13
#WITHOUT ANY WARRANTY; without even the implied warranties of
14
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
#PURPOSE. See the GNU General Public License for more details.
17
#You should have received a copy of the GNU General Public License along
18
#with this program. If not, see <http://www.gnu.org/licenses/>.
25
from quickly import templatetools
26
from internal import quicklyutils
29
from gettext import gettext as _
31
gettext.textdomain('quickly')
37
$ quickly create ubuntu-project path/to/project_name
39
where "project_name" is one or more words separated by an underscore and
40
path/to can be any existing path.
42
This will create and run a new project, including Python code,
43
Glade files, and packaging files to make the project work. After
44
creating the project, get started by:
46
1. Changing your working directory to the new project:
47
$ cd path/to/project_name
49
2. Edit the UI with Glade:
52
3. Edit the Python code:
55
templatetools.handle_additional_parameters(sys.argv, help)
58
pathname = os.path.dirname(__file__)
59
abs_path = os.path.abspath(pathname) + "/"
62
# get the name of the project
65
ERROR: project name not defined. Usage is project_name""")
70
path_and_project = sys.argv[1].split('/')
71
project_name = path_and_project[-1]
73
# check that project name follow quickly rules and reformat it.
74
project_name = templatetools.quickly_name(project_name)
76
# create additional directories
78
print _("Creating project directory %s") % data_dir
80
print _("Directory %s created\n") % data_dir
82
python_dir = project_name
83
print _("Creating project directory %s") % python_dir
85
print _("Directory %s created\n") % python_dir
88
print _("Creating project directory %s") % bin_dir
90
print _("Directory %s created\n") % bin_dir
92
sentence_name, camel_case_name = quicklyutils.conventional_names(project_name)
95
template_ui_dir = abs_path + "data/ui/"
96
target_ui_dir = "data/ui"
97
os.mkdir(target_ui_dir)
99
substitutions = (("project_name",project_name),
100
("camel_case_name",camel_case_name),
101
("sentence_name",sentence_name),)
104
# create the files for glade to use
105
quicklyutils.file_from_template(template_ui_dir, "camel_case_nameWindow.ui", target_ui_dir, substitutions)
106
quicklyutils.file_from_template(template_ui_dir, "project_name_window.xml", target_ui_dir, substitutions)
107
quicklyutils.file_from_template(template_ui_dir, "Aboutcamel_case_nameDialog.ui", target_ui_dir, substitutions)
108
quicklyutils.file_from_template(template_ui_dir, "about_project_name_dialog.xml", target_ui_dir, substitutions)
109
quicklyutils.file_from_template(template_ui_dir, "Preferencescamel_case_nameDialog.ui", target_ui_dir, substitutions)
110
quicklyutils.file_from_template(template_ui_dir, "preferences_project_name_dialog.xml", target_ui_dir, substitutions)
112
# create the python directory and files
113
template_python_dir = abs_path + "python/"
114
target_python_dir = project_name
115
quicklyutils.file_from_template(template_python_dir, "Aboutcamel_case_nameDialog.py", target_python_dir, substitutions)
116
quicklyutils.file_from_template(template_python_dir, "Preferencescamel_case_nameDialog.py", target_python_dir, substitutions)
117
quicklyutils.file_from_template(template_python_dir, "project_nameconfig.py", target_python_dir, substitutions)
119
# copy the files needed for packaging
120
quicklyutils.file_from_template(abs_path, "project_root/setup.py", ".", substitutions)
121
quicklyutils.file_from_template(template_python_dir, "__init__.py", target_python_dir)
123
# create the media directory, and copy them
124
template_media_dir = abs_path + "data/media"
125
target_media_dir = "data/media"
126
shutil.copytree(template_media_dir,target_media_dir)
128
# copy the desktop file
129
quicklyutils.file_from_template(abs_path ,"project_root/project_name.desktop.in",".", substitutions)
131
# copy the executable file, set the mode to executable
132
quicklyutils.file_from_template(abs_path ,"bin/project_name","bin", substitutions)
133
os.chmod("bin/" + project_name, 0755)
135
# copy the licence file
136
quicklyutils.file_from_template(abs_path ,"project_root/Copyright",".", substitutions)
138
# add it to revision control
139
print _("Creating bzr repository and commiting")
140
subprocess.call(["bzr", "init"])
141
subprocess.call(["bzr", "add"])
142
subprocess.call(["bzr", "commit", "-m", "Initial project creation with Quickly!"])
144
# run the new application
145
print _("Launching your newly created project!")
146
subprocess.call(['./' + project_name], cwd='bin/')
148
print _("Congrats, your new project is setup! cd %s/ to start hacking. Then '$ quickly tutorial' for quickly ubuntu-template tutorial and reference") % os.getcwd()