Changeset 3650
- Timestamp:
- 11/10/07 20:39:22 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/turbogears/command/quickstart.py
r3646 r3650 17 17 beginning_letter = re.compile(r"^[^a-z]*") 18 18 valid_only = re.compile(r"[^a-z0-9_]") 19 19 20 20 21 class TGTemplate(templates.Template): … … 33 34 super(TGTemplate, self).run(command, output_dirs, vars) 34 35 36 35 37 class BaseTemplate(TGTemplate): 36 38 egg_plugins = ["TurboGears"] … … 42 44 use_cheetah = True 43 45 46 44 47 class TurbogearsTemplate(TGTemplate): 45 48 required_templates = ["tgbase"] … … 49 52 summary = "web framework" 50 53 use_cheetah = True 54 51 55 52 56 class TGBig(TGTemplate): … … 72 76 print "There is currently a controllers package and a" 73 77 print "controllers module, which would get confusing." 74 if controllerstext == roottext or \75 query_interactive(controllersfile, rootfile,76 controllerstext, roottext, False):78 if not command.simulate and (controllerstext == roottext 79 or query_interactive(controllersfile, rootfile, 80 controllerstext, roottext, False)): 77 81 shutil.copyfile(controllersfile, rootfile) 78 os.unlink(controllersfile) 82 try: 83 if not os.path.exists(os.path.join(os.path.dirname( 84 os.path.abspath(controllersfile)), '.svn')): 85 raise OSError 86 command.run_command('svn', 'delete', controllersfile) 87 except OSError: 88 os.unlink(controllersfile) 79 89 controllerspyc = controllersfile + "c" 80 90 if os.path.exists(controllerspyc): 81 91 os.unlink(controllerspyc) 92 82 93 83 94 class TGWidgetTemplate(TGTemplate): … … 88 99 summary = "TurboGears widget projects" 89 100 101 90 102 class quickstart: 91 103 "Implementation of quickstart." … … 96 108 package = None 97 109 templates = "turbogears" 110 svn_repository = None 98 111 sqlalchemy = False 99 112 sqlobject = False … … 111 124 help="dry run (don't actually do anything)", 112 125 action="store_true", dest="dry_run") 126 parser.add_option("--svn", metavar="REPOS", 127 help="Create new project at given repository location", 128 dest="svn_repository", default = self.svn_repository) 113 129 parser.add_option("-t", "--templates", 114 130 help="user specific templates", … … 127 143 action="store_true", dest="identity", default = False) 128 144 129 (options, args)= parser.parse_args()145 options, args = parser.parse_args() 130 146 self.__dict__.update(options.__dict__) 131 147 if not True in [self.elixir, self.sqlalchemy, self.sqlobject]: … … 175 191 env = pkg_resources.Environment() 176 192 if self.name.lower() in env: 177 print "the name %s is already in use by" %self.name,193 print 'The name "%s" is already in use by' % self.name, 178 194 for dist in env[self.name]: 179 195 print dist … … 183 199 try: 184 200 if imp.find_module(self.package): 185 print "the package name %s is already in use"% self.package201 print 'The package name "%s" is already in use' % self.package 186 202 return 187 203 except ImportError: … … 189 205 190 206 if os.path.exists(self.name): 191 print("A directory called '%s' already exists. Exiting." 192 % self.name) 207 print 'A directory called "%s" already exists. Exiting.' % self.name 193 208 return 194 209 … … 197 212 for template in self.templates.split(" "): 198 213 cmd_args.append("--template=%s" % template) 214 if self.svn_repository: 215 cmd_args.append("--svn-repository=%s" % self.svn_repository) 199 216 cmd_args.append(self.name) 200 217 cmd_args.append("package=%s" % self.package) … … 210 227 if not self.dry_run: 211 228 os.chdir(self.name) 212 sodir = '%s/sqlobject-history' % self.package 213 if self.sqlobject and not os.path.exists(sodir): 214 os.mkdir(sodir) 229 if self.sqlobject: 230 # Create the SQLObject history directory only when needed. 231 # With paste.script it's only possible to skip files, but 232 # not directories. So we are handling this manually. 233 sodir = '%s/sqlobject-history' % self.package 234 if not os.path.exists(sodir): 235 os.mkdir(sodir) 236 try: 237 if not os.path.exists(os.path.join(os.path.dirname( 238 os.path.abspath(sodir)), '.svn')): 239 raise OSError 240 command.run_command('svn', 'add', sodir) 241 except OSError: 242 pass 215 243 startscript = "start-%s.py" % self.package 216 244 if os.path.exists(startscript): … … 222 250 imp.load_module("setup", *imp.find_module("setup", ["."])) 223 251 224 # dirty hack to allow "empty" dirs225 for base,path,files in os.walk("./"):226 for file in files:227 if file == "empty":228 os.remove(os.path.join(base, file))229 252 230 253 class update: … … 258 281 help="provide Identity support", 259 282 action="store_true", dest="identity", default = False) 260 (options, args)= parser.parse_args()283 options, args = parser.parse_args() 261 284 self.__dict__.update(options.__dict__) 262 285 self.turbogearsversion = version … … 293 316 currentdir = os.path.basename(os.getcwd()) 294 317 if not currentdir == self.name: 295 print 'it looks like your project dir "%s" is named wrongly. Please rename it to "%s"' %(currentdir, self.name) 318 print 'It looks like your project dir "%s" is named wrongly.' % currentdir 319 print 'Please rename it to "%s".' % self.name 296 320 return 297 321 … … 317 341 import imp 318 342 imp.load_module("setup", *imp.find_module("setup", ["."])) 319 320 # dirty hack to allow "empty" dirs321 for base,path,files in os.walk("./"):322 for file in files:323 if file == "empty":324 os.remove(os.path.join(base, file))