1
# -*- coding: utf-8 -*-
2
# Copyright 2009 Canonical Ltd.
3
# Author 2009 Didier Roche
5
# This file is part of Quickly ubuntu-project-template
7
#This program is free software: you can redistribute it and/or modify it
8
#under the terms of the GNU General Public License version 3, as published
9
#by the Free Software Foundation.
11
#This program is distributed in the hope that it will be useful, but
12
#WITHOUT ANY WARRANTY; without even the implied warranties of
13
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
#PURPOSE. See the GNU General Public License for more details.
16
#You should have received a copy of the GNU General Public License along
17
#with this program. If not, see <http://www.gnu.org/licenses/>.
20
$quickly create ubuntu-project path/to/project_name
22
where "project_name" is one or more words separated by an underscore and
23
path/to can be any existing path.
25
This will create and run a new project, including Python code,
26
Glade files, and packaging files to make the project work. After
27
creating the project, get started by:
29
1. Changing your working directory to the new project:
30
$cd path/to/project_name
32
2. Edit the UI with Glade:
35
3. Edit the Python code:
45
from quickly import tools
46
from internal import quicklyutils
49
from gettext import gettext as _
53
gettext.textdomain('quickly')
56
pathname = os.path.dirname(__file__)
57
abs_path = os.path.abspath(pathname) + "/"
60
# get the name of the project
63
ERROR: project name not defined. Usage is project_name""")
66
path_and_project = sys.argv[1].split('/')
67
project_name = path_and_project[-1]
69
# check that project name follow quickly rules and reformat it.
70
project_name = tools.quickly_name(project_name)
72
# create additional directories
74
print _("Creating project directory %s") % data_dir
76
print _("Directory %s created\n") % data_dir
78
python_dir = project_name
79
print _("Creating project directory %s") % python_dir
81
print _("Directory %s created\n") % python_dir
84
print _("Creating project directory %s") % bin_dir
86
print _("Directory %s created\n") % bin_dir
88
sentence_name, camel_case_name = quicklyutils.conventional_names(project_name)
91
template_ui_dir = abs_path + "data/ui/"
92
target_ui_dir = "data/ui"
93
os.mkdir(target_ui_dir)
95
substitutions = (("project_name",project_name),
96
("camel_case_name",camel_case_name),
97
("sentence_name",sentence_name),)
100
# create the files for glade to use
101
quicklyutils.file_from_template(template_ui_dir, "camel_case_nameWindow.ui", target_ui_dir, substitutions)
102
quicklyutils.file_from_template(template_ui_dir, "project_name_window.xml", target_ui_dir, substitutions)
103
quicklyutils.file_from_template(template_ui_dir, "Aboutcamel_case_nameDialog.ui", target_ui_dir, substitutions)
104
quicklyutils.file_from_template(template_ui_dir, "about_project_name_dialog.xml", target_ui_dir, substitutions)
105
quicklyutils.file_from_template(template_ui_dir, "Preferencescamel_case_nameDialog.ui", target_ui_dir, substitutions)
106
quicklyutils.file_from_template(template_ui_dir, "preferences_project_name_dialog.xml", target_ui_dir, substitutions)
108
# create the python directory and files
109
template_python_dir = abs_path + "python/"
110
target_python_dir = project_name
111
quicklyutils.file_from_template(template_python_dir, "Aboutcamel_case_nameDialog.py", target_python_dir, substitutions)
112
quicklyutils.file_from_template(template_python_dir, "Preferencescamel_case_nameDialog.py", target_python_dir, substitutions)
113
quicklyutils.file_from_template(template_python_dir, "project_nameconfig.py", target_python_dir, substitutions)
115
# copy the files needed for packaging
116
quicklyutils.file_from_template(abs_path, "project_root/setup.py", ".", substitutions)
117
quicklyutils.file_from_template(template_python_dir, "__init__.py", target_python_dir)
119
# create the media directory, and copy them
120
template_media_dir = abs_path + "data/media"
121
target_media_dir = "data/media"
122
shutil.copytree(template_media_dir,target_media_dir)
124
# copy the desktop file
125
quicklyutils.file_from_template(abs_path ,"project_root/project_name.desktop.in",".", substitutions)
127
# copy the executable file, set the mode to executable
128
quicklyutils.file_from_template(abs_path ,"bin/project_name","bin", substitutions)
129
os.chmod("bin/" + project_name, 0755)
131
# copy the licence file
132
quicklyutils.file_from_template(abs_path ,"project_root/Copyright",".", substitutions)
134
# add it to revision control
135
print _("Creating bzr repository and commiting")
136
subprocess.call(["bzr", "init"])
137
subprocess.call(["bzr", "add"])
138
subprocess.call(["bzr", "commit", "-m", "Initial project creation with Quickly!"])
140
# run the new application
141
print _("Launching your newly created project!")
142
subprocess.call(['./' + project_name], cwd='bin/')
144
# put project name in setup.py
145
quicklyutils.set_setup_value('name', project_name)
147
print _("Congrats, your new project is setup! cd %s/ to start hacking. Then '$ quickly help' for quickly tutorial and reference") % os.getcwd()