Home | Trees | Indices | Help |
|
---|
|
1 # ============================================================================ 2 # 3 # Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved. 4 # www.conceptive.be / project-camelot@conceptive.be 5 # 6 # This file is part of the Camelot Library. 7 # 8 # This file may be used under the terms of the GNU General Public 9 # License version 2.0 as published by the Free Software Foundation 10 # and appearing in the file LICENSE.GPL included in the packaging of 11 # this file. Please review the following information to ensure GNU 12 # General Public Licensing requirements will be met: 13 # http://www.trolltech.com/products/qt/opensource.html 14 # 15 # If you are unsure which license is appropriate for your use, please 16 # review the following information: 17 # http://www.trolltech.com/products/qt/licensing.html or contact 18 # project-camelot@conceptive.be. 19 # 20 # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21 # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 # 23 # For use of this library in commercial applications, please contact 24 # project-camelot@conceptive.be 25 # 26 # ============================================================================ 27 28 from optparse import OptionParser 29 30 # 31 # Description of the application, out of which the help text as well as the 32 # __doc__ strings can be generated 33 # 34 35 description = """camelot_admin is a tool to assist in the creation and development of Camelot 36 projects. 37 """ 38 39 usage = "usage: %prog [options] command" 40 41 command_description = [ 42 ('startproject', """Starts a new project, use startproject project_name."""), 43 ('makemessages', """Outputs a message file with all field names of all entities. This command 44 requires settings.py of the project to be in the PYTHONPATH"""), 45 ] 46 47 # 48 # Generate a docstring in restructured text format 49 # 50 51 __doc__ = description 52 53 for command, desc in command_description: 54 __doc__ += "\n.. cmdoption:: %s\n\n"%command 55 for line in desc.split('\n'): 56 __doc__ += " %s\n"%line 57 58 # 59 # A custom OptionParser that generates help information on the commands 60 #627564 command_help = """ 65 The available commands are : 66 67 """ 68 command_help += '\n\n'.join(['%s\n%s\n%s'%(command,'-'*len(command), desc) for command,desc in command_description]) 69 command_help += """ 70 71 For the management of deployed Camelot applications, see camelot_manage 72 73 """ 74 return OptionParser.format_help(self) + ''.join(command_help)77 import shutil, os, sys 78 if os.path.exists(project): 79 raise Exception('Directory %s allready exists, cannot start a project in it'%project) 80 81 def ignore(directory, content): 82 """ignore .svn files""" 83 for c in content: 84 if c.startswith('.'): 85 yield c86 87 # ignore is only supported as of python 2.6 88 v = sys.version_info 89 if v[0]>2 or (v[0]==2 and v[1]>=6): 90 shutil.copytree(os.path.join(os.path.dirname(__file__), '..', 'empty_project'), 91 project, ignore=ignore) 92 else: 93 shutil.copytree(os.path.join(os.path.dirname(__file__), '..', 'empty_project'), 94 project) 95 # creating a repository doesn't seems to work when migrate is easy intalled 96 #from migrate.versioning.api import create 97 #create(os.path.join(project, 'repository'), project) 98 103 104 105 commands = locals() 106108 import camelot 109 parser = CommandOptionParser(description=description, 110 usage=usage, 111 version=camelot.__version__,) 112 (_options, args) = parser.parse_args() 113 if not len(args)==2: 114 parser.print_help() 115 else: 116 command, _project = args 117 commands[command](*args[1:])118 119 if __name__ == '__main__': 120 main() 121
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 12 15:42:13 2010 | http://epydoc.sourceforge.net |