Changeset 3317

Show
Ignore:
Timestamp:
08/21/2007 09:21:40 AM (1 year ago)
Author:
ed
Message:

Added a couple of convenience methods: makeDaboDirectories() and quickStart(). These are for setting up a standard Dabo directory structure, along with a 'main.py' to be used as the startup script for an app.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/__init__.py

    r3290 r3317  
    101101""" 
    102102 
     103import os 
    103104import sys 
    104105try: 
     
    161162import dabo.biz 
    162163import dabo.ui 
     164 
     165 
     166# Method to create a standard Dabo directory structure layout 
     167def makeDaboDirectories(homedir=None): 
     168    """If homedir is passes, the directories will be created off of that 
     169    directory. Otherwise, it is assumed that they should be created 
     170    in the current directory location. 
     171    """ 
     172    currLoc = os.getcwd() 
     173    if homedir is not None: 
     174        os.chdir(homedir) 
     175    for d in ("biz", "db", "ui", "resources", "reports"): 
     176        if not os.path.exists(d): 
     177            os.mkdir(d) 
     178    os.chdir(currLoc) 
     179 
     180 
     181def quickStart(homedir=None): 
     182    """This creates a bare-bones application in either the specified  
     183    directory, or the current one if none is specified. 
     184    """ 
     185    currLoc = os.getcwd() 
     186    if homedir is not None: 
     187        os.chdir(homedir) 
     188    makeDaboDirectories() 
     189    open("main.py", "w").write("""#!/usr/bin/env python 
     190# -*- coding: utf-8 -*- 
     191import dabo 
     192 
     193app = dabo.dApp() 
     194app.start() 
     195""") 
     196    os.chmod("main.py", 0744) 
     197    os.chdir(currLoc) 
     198