~mhall119/quickly/reboot-proposed

« back to all changes in this revision

Viewing changes to data/templates/ubuntu-application/commands.py

  • Committer: Michael Hall
  • Date: 2012-10-24 12:09:39 UTC
  • Revision ID: mhall119@ubuntu.com-20121024120939-g0smpquq4lyoxahz
Start on re-creating ubuntu-application template

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from quickly.core.commands import BaseCommand
 
1
from quickly.core.commands import BaseCommand, CommandError
 
2
import logging
 
3
from locale import gettext as _
 
4
import os
2
5
 
3
6
class Create(BaseCommand):
4
7
    
6
9
        name = 'Create'
7
10
        icon = 'gtk-new'
8
11
        
 
12
    def mkdir(self, dirname):
 
13
        return os.path.join(os.getcwd(), dirname)
 
14
        
 
15
    def copy_project_files(self, path):
 
16
        pass
 
17
        
 
18
    def process_project_files(self, path):
 
19
        pass
 
20
        
 
21
    def rename_dir(self, dir_path):
 
22
        pass
 
23
        
 
24
    def rename_file(self, file_path):
 
25
        pass
 
26
        
 
27
    def replace_file_content(self, file_path):
 
28
        pass
 
29
        
 
30
    def init_version_control(self, path):
 
31
        pass
 
32
        
9
33
    def run(self, args):
10
 
        print "Creating %s project with args: %s" % (self.template._meta.name, args)
 
34
        if len(args) < 1:
 
35
            logging.warn(_('No project name argument'))
 
36
            raise CommandError(self, _('Create command requires a project name'))
 
37
        logging.info(_("Creating %s project with args: %s" % (self.template._meta.name, args)))
 
38
        
 
39
        project_name = os.path.basename(args[0])
 
40
        logging.info(_('Project name: %s' % project_name))
 
41
        
 
42
        new_project_path = self.mkdir(args[0])
 
43
        logging.info(_('Adding project files to %s' % new_project_path))
 
44
        self.copy_project_files(new_project_path)
 
45
        self.process_project_files(new_project_path)
 
46
        self.init_version_control(new_project_path)
11
47
 
 
48
        logging.info(_('Finished creating project'))