~ubuntu-branches/ubuntu/natty/quickly/natty

« back to all changes in this revision

Viewing changes to quickly/builtincommands.py

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-03-29 19:00:48 UTC
  • mfrom: (8.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100329190048-olhobq492x3xnztz
Tags: 0.3.90-0ubuntu1
* New release:
  Quickly core:
  - check now that --template has one argument
  - -- enables to give options to templates (unknown options and arguments
    are still given to templates but -- specify explicity what to give to
    templates commands like -h, --version...)
  - check and enable recreation of the credential if user deletes it on
    Launchpad
  - Use realpath so that we can symlink to the binary in trunk.
    (Jonathan Lange)
  - project_path_not_found is raised when data_path_not_found should be
    (originated from Philip Peitsch's patch). (LP: #497688)
  - importing command in one template from another template is now possible
    support as well "all" keyword to import all commands from a template
    into another one (take care of overridden commands too)
    (LP: #452306, #487301)
  - add an apport hook to get installed templates (LP: #411127)
  - enable option completion for templates
  - handle now version upgrade, launching script for templates and handling
    versionning on them
  - change getstarted wording (LP: #486180) - Grant
  - Quickly ship now "version" tag instead of "format" tag
  - add some templatetools to check X display
  - if a commands exit with 4, do not show "ERROR:" (case of wrong command
    usage, for instance)
  - Rewrote importing module in both bin/quickly and ubuntu-project binary
  - Add get_camel_case_name() and get_sentence_name() to templatetools
  - Refactor some code in pre_create hook()
  - Now dashes and spaces support in project name! Dealing with python and
    packaging issues for you. (LP: #493130)
  - Provide Quickly API (LP: #426480)
  - Fix some issues in the man page
  ubuntu-application Template:
  - Enabling upload to team or user ppa, as well as any ppa.
    Use --ppa ppaname or --ppa team/ppaname
    .quickly file can be used as well with ppa = ppaname or
    ppa = team/ppaname (LP: #470192)
    ppa completion is also available
  - Change BSD header by full license
  - Add MIT license
  - Fixes an error when launchpad display name contains unicode character
    (Petar Vasić)
  - Fix typo in quickly help save (Petar Vasić)
  - Adds logo.png as logo property in about dialog (LP: #478389)
    (Petar Vasić)
  - Remove lp-project-change command and add configure command.
    configure lp-project [project_name] to set/reset lp project binded to
    your Quickly project
    ppa <ppa name> to set a default ppa with your project
  - Fix ~/.selected-editor being ignored (LP: #484730)
  - Fix wrong shell completion when in a template (it wrongly proposed
    all commands followed by templates)
  - Check if we have a X display available before running "run" or launching
    GUI in "create" command.
  - add -- support in quickly run to pass options like --help, --version so
    that Quickly core don't take them.
  - enable preferences save call being called multiple times (Philip Peitsch)
  - Use realpath so that we can symlink to the binary in trunk.
  - Fixed some errors in the tutorial (Brian) (LP: #499356)
  - Fix missing import sys in setup.py (Philip Peitsch) (LP: #499712)
  - rename ubuntu-project to ubuntu-application
  - enhance quickly license (no more Copyright file, only one AUTHORS file)
    personal license needs COPYING file now (and the header will be copied in
    every files). No more # needed in those files too. Some other little
    refactoring too (LP: #469330)
  - autolicence by default on first share/release (with LP info and on GPL-3)
  - change versionning support in ubuntu application: (LP: #476814)
   + quickly share just adds -publicX to current version where X is bumped
     at each "quicky share" execution
   + quickly release remove -publicX (if any) and release with current YY.MM.
     If there is already a release with that version, it will be YY.MM.1, 
     then YY.MM.2
  - add accelerators to menu items (jens persson)
  - set correctly title dialog (Philip Peitsch) (LP: #501999)
  - about dialog box is now fully automated: (LP: #478414)
   + update copyright, authors, license (when licensing)
   + version (when sharing and releasing)
   + homepage (when changing launchpad project: release and configure)
  - add an 'add' command. $ quickly dialog … is now $ quickly add dialog …
    (LP: #438320)
  - enable automatic release and milestone built in LP, releasing and pushing
    upstream tarball (LP: #470344)
  - automatic collect and publish changelog message from commits and save
    messages used during devlopment. (LP: #476572)
  - add i18n to boiler plate (LP: #423529)
  - enable adding manual depdencies to quickly project (LP: #474639)
  - enable configure its own bzr branch and resetting parent branch even once
    already configured (quickly configure bzr <branch-path>)
  - now recommends seahorse-plugins to have a graphical prompt for signing
    package
  - rename quickly glade to quickly design (LP: #528664)
  - create command is now more flexible and enable people to inherit from
    other template more easily
  - add translation domain to gtkbuilder and fix some items that shouldn't
    been translatable (Łukasz Jernaś)
  - add apport and launchpadintegration to new and existing project once
    bounded to LP (Philip Peitsch)
  - fix spelling mistake "connexion" (Łukasz Jernaś) (LP: #532667)
  - the ubuntu-application tutorial is now internationalized and use docbook
    format. Translators, it's yours! (Shane Fagan) (LP: #525168)
  - package/share/release are now more quiet and only print something on error
    warning as a summary as with unfound packages, and so on (LP: #482915)
  - new algorithm to select good email automatically. Try to get the preferred
    email and update the AUTHOR file with it.
  - test GPG key and create one automatically if none is available. The
    corresponding public key availabity in launchpad is also checked.
    (LP: #427730, #408993)
  - add devscripts as a dependency (bug #465833), will fix all the depends
    mess later
  - bump python-distutils-extra (>= 2.18bzr1)
  ubuntu-cli Template:
  - first release using import command feature (no command written into the
    template itself). This is a basic ubuntu CLI application
  ubuntu-pygame Template:
  - first release using import command feature. python-pygame added as a
    depends
* debian/control:
  - renamed and separate in multiple packages to get a -common used with
    Quickly widgets (LP: #519633)
  - suggests python-quickly-widgets

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
 
# Copyright 2009 Canonical Ltd.
3
 
# Author 2009 Didier Roche
 
2
# Copyright 2009 Didier Roche
4
3
#
5
4
# This file is part of Quickly
6
5
#
29
28
from gettext import gettext as _
30
29
 
31
30
 
32
 
def pre_create(template, project_dir, command_args):
 
31
def pre_create(command_template, project_template, project_dir, command_args):
33
32
    """Create the project directory before create command call"""
34
33
 
35
34
    if len(command_args) < 1:
36
 
        print _("ERROR: Create command must be followed by a template and a project path")
37
 
        return(1)
38
 
        
 
35
        print _("Create command must be followed by a template and a project path.\nUsage: quickly create <template> <project_name>")
 
36
        return(4)
 
37
 
39
38
    path_and_project = command_args[0].split('/')
40
39
    project_name = path_and_project[-1]
41
40
    
48
47
        os.chdir(path)
49
48
    
50
49
    # check that project name follow quickly rules and reformat it.
51
 
    quickly_project_name = templatetools.quickly_name(project_name)
 
50
    try:
 
51
        project_name = templatetools.quickly_name(project_name)
 
52
    except templatetools.bad_project_name, e:
 
53
        print(e)
 
54
        return(1)
52
55
 
53
56
    #bail if the name if taken
54
57
    if os.path.exists(project_name):
58
61
    #create directory and template file
59
62
    print _("Creating project directory %s" % project_name)
60
63
    os.mkdir(project_name)
61
 
    print _("Directory %s created\n" % project_name)
62
64
 
63
65
    # creating quickly file
64
 
    configurationhandler.project_config['format'] = quicklyconfig.__version__
65
 
    configurationhandler.project_config['project'] = quickly_project_name
66
 
    configurationhandler.project_config['template'] = template
 
66
    configurationhandler.project_config['version'] = quicklyconfig.__version__
 
67
    configurationhandler.project_config['project'] = project_name
 
68
    configurationhandler.project_config['template'] = project_template
67
69
    configurationhandler.saveConfig(config_file_path=project_name)
68
70
    
69
71
    os.chdir(project_name)
70
72
 
71
73
    return 0
72
74
 
73
 
def commands(template, project_dir, command_args, shell_completion=False):
 
75
def commands(project_template, project_dir, command_args, shell_completion=False):
74
76
    """List all commands ordered by templates"""
75
77
 
76
78
    # We have nothing for this
88
90
            
89
91
    return(0)
90
92
    
91
 
def getstarted(template, project_dir, command_args, shell_completion=False):
 
93
def getstarted(project_template, project_dir, command_args, shell_completion=False):
92
94
    """ Give some getstarted advice"""
93
95
 
94
96
    # We have nothing for this
99
101
    Welcome to quickly!
100
102
-------------------------------
101
103
 
102
 
You can create a project in executing 'quickly create <template_name> <your project>'.
103
 
 
104
 
 
105
 
Example with ubuntu-project template:
106
 
1. create a Ubuntu Project and run the tutorial:
107
 
$ quickly create ubuntu-project foo
 
104
You can create a project by executing 'quickly create <template_name> <your project>'.
 
105
 
 
106
Example with ubuntu-application template:
 
107
1. create an ubuntu application and run the tutorial:
 
108
$ quickly create ubuntu-application foo
108
109
$ cd foo
109
110
$ quickly tutorial
110
111
 
111
112
2. You can also try:
112
113
$ quickly edit
113
 
$ quickly glade
 
114
$ quickly design
114
115
$ quickly run
115
 
Use bash completion to get every available commands
116
 
 
117
 
3. How to play with package and release:
118
 
 
119
 
optional, but recommended to build first your package locally:
 
116
Use bash completion to get every available command
 
117
 
 
118
3. How to play with a package and release it:
 
119
 
 
120
Optional (but recommended): build your package locally:
120
121
$ quickly package
121
122
 
122
 
BE WARNED: the two following commands will connect to Launchpad. You need at least having a Launchpad account and an opened ppa.
123
 
You need also for quickly release a project where you can bind your work with.
 
123
BE WARNED: the two following commands will connect to Launchpad. Make sure that you have a Launchpad account and a PPA! You can find out more about setting up a Launchpad account and Launchpad features at https://launchpad.net/
124
124
$ quickly release or $ quickly share
125
125
 
126
126
Have Fun!''')
127
127
    return 0
128
128
 
129
 
def help(template, project_dir, command_args, shell_completion=False):
 
129
def help(project_template, project_dir, command_args, shell_completion=False):
130
130
    """Get help from commands"""
131
131
 
132
132
    # We have nothing for this
136
136
    if len(command_args) > 0:
137
137
        command_name = command_args[0]
138
138
    else:
139
 
        print _("ERROR: No command provided to help command")
140
 
        return(1)
 
139
        print _("No command provided to help command.\nUsage is: quickly help [template] <command>")
 
140
        return(4)
141
141
 
 
142
    template = project_template
142
143
    if template is None:
143
144
        template = "builtins"
144
145
    try:
145
 
        command = commands_module.get_command_by_criteria(name=command_name, template=template)[0]
 
146
        command = commands_module.get_commands_by_criteria(name=command_name, template=project_template)[0]
146
147
    except IndexError:
147
148
        # check if a builtin commands corresponds
148
149
        template = "builtins"
149
150
        try:
150
 
            command = commands_module.get_command_by_criteria(name=command_name, template=template)[0]
 
151
            command = commands_module.get_commands_by_criteria(name=command_name, template=template)[0]
151
152
        except IndexError:       
152
153
            # there is really not such command
153
154
            if template == "builtins":
154
155
                # to help the user, we can search if this command_name corresponds to a command in a template
155
 
                list_possible_commands = commands_module.get_command_by_criteria(name=command_name, followed_by_template=True)
 
156
                list_possible_commands = commands_module.get_commands_by_criteria(name=command_name, followed_by_template=True)
156
157
                if list_possible_commands:
157
 
                   print _("ERROR: help command must be followed by a template name for getting help from templates commands like %s." % command_name)
158
 
                   print _("Candidates template are: %s") % ", ".join([command.template for command in list_possible_commands])
 
158
                    proposed_templates = []
 
159
                    for template in commands_module.get_all_templates():
 
160
                        try:
 
161
                            commands_module.get_all_commands()[template][command_name]
 
162
                            proposed_templates.append(template)
 
163
                        except KeyError:
 
164
                            pass
 
165
                    print _("help command must be followed by a template name for getting help from templates commands like %s.\nUsage is: quickly help [template] <command>" % command_name)
 
166
                    print _("Candidates template are: %s") % ", ".join(proposed_templates)
 
167
                    return(4)
159
168
                else:
160
169
                    print _("ERROR: No %s command found.") % command_name
161
170
            else:
165
174
    return(command.help(project_dir, command_args))
166
175
 
167
176
 
168
 
def quickly(template, project_dir, command_args, shell_completion=False):
 
177
def quickly(project_template, project_dir, command_args, shell_completion=False):
169
178
    """Create a new quickly template from an existing one"""
170
179
 
171
180
    # We have nothing for this
173
182
        return("")
174
183
 
175
184
    if len(command_args) < 1:
176
 
        print _("ERROR: Quickly command must be followed by a template and a template destination path")
177
 
        return(1)
 
185
        print _("Quickly command must be followed by a template and a template destination path\nUsage is: quickly quickly [origin_template] destination_template")
 
186
        return(4)
178
187
 
179
188
    destination_path = os.path.expanduser("~/quickly-templates/")
180
189
    # create ~/quickly-templates/ if needed
187
196
        return 1
188
197
 
189
198
    if not os.path.exists(template_destination_path):
190
 
        print _("Copy %s to create new %s template") % (template, template_destination_path)
 
199
        print _("Copy %s to create new %s template") % (project_template, template_destination_path)
191
200
 
192
201
    try:
193
 
        template_source_path = tools.get_template_directory(template)
194
 
    except (tools.no_template_path_not_found, e):
 
202
        template_source_path = tools.get_template_directory(project_template)
 
203
    except tools.template_path_not_found, e:
 
204
        print(e)
 
205
        return 1
 
206
    except tools.template_not_found, e:
195
207
        print(e)
196
208
        return 1
197
209