本文整理汇总了Python中uliweb.utils.common.extract_dirs函数的典型用法代码示例。如果您正苦于以下问题:Python extract_dirs函数的具体用法?Python extract_dirs怎么用?Python extract_dirs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extract_dirs函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
def handle(self, options, global_options, *args):
from uliweb.utils.common import extract_dirs
if not options.outputdir:
print >>sys.stderr, "Error: please give the output directory with '-d outputdir' argument"
sys.exit(0)
else:
outputdir = options.outputdir
if not args:
apps = self.get_apps(global_options)
else:
apps = args
if not os.path.exists(outputdir):
os.makedirs(outputdir)
for app in apps:
dirs = app.split('.')
mod = []
dest = outputdir
for m in dirs:
mod.append(m)
dest = os.path.join(dest, m)
module = '.'.join(mod)
if global_options.verbose:
print 'Export %s to %s ...' % (module, dest)
if module == app:
recursion = True
else:
recursion = False
extract_dirs(module, '', dest, verbose=global_options.verbose, recursion=recursion)
示例2: handle
def handle(self, options, global_options, *args):
from uliweb.utils.common import extract_dirs
from uliweb.core.template import template_file
if not args:
project_name = ''
while not project_name:
project_name = raw_input('Please enter project name:')
else:
project_name = args[0]
ans = '-1'
if os.path.exists(project_name):
if options.force:
ans = 'y'
while ans not in ('y', 'n'):
ans = raw_input('The project directory has been existed, do you want to overwrite it?(y/n)[n]')
if not ans:
ans = 'n'
else:
ans = 'y'
if ans == 'y':
extract_dirs('uliweb', 'template_files/project', project_name, verbose=global_options.verbose)
#template setup.py
setup_file = os.path.join(project_name, 'setup.py')
text = template_file(setup_file, {'project_name':project_name})
with open(setup_file, 'w') as f:
f.write(text)
#rename .gitignore.template to .gitignore
os.rename(os.path.join(project_name, '.gitignore.template'), os.path.join(project_name, '.gitignore'))
示例3: handle
def handle(self, options, global_options, *args):
from uliweb.utils.common import extract_dirs
from uliweb.core.template import template_file
from uliweb.manage import make_simple_application
from uliweb import settings
from sqlalchemy import create_engine, MetaData, Table
from shutil import rmtree
from uliweb.orm import get_connection, engine_manager
alembic_path = os.path.join(global_options.project, 'alembic', options.engine).replace('\\', '/')
#delete alembic path
if os.path.exists(alembic_path):
rmtree(alembic_path, True)
extract_dirs('uliweb.contrib.orm', 'templates/alembic', alembic_path,
verbose=global_options.verbose, replace=True)
make_simple_application(project_dir=global_options.project,
settings_file=global_options.settings,
local_settings_file=global_options.local_settings)
ini_file = os.path.join(alembic_path, 'alembic.ini')
text = template_file(ini_file,
{'connection':engine_manager[options.engine].options.connection_string,
'engine_name':options.engine,
'script_location':alembic_path})
with open(ini_file, 'w') as f:
f.write(text)
#drop old alembic_version table
db = get_connection(engine_name=options.engine)
metadata = MetaData(db)
if db.dialect.has_table(db.connect(), 'alembic_version'):
version = Table('alembic_version', metadata, autoload=True)
version.drop()
示例4: handle
def handle(self, options, global_options, *args):
if not args:
appname = ""
while not appname:
appname = raw_input("Please enter app name:")
else:
appname = args[0]
ans = "-1"
app_path = appname.replace(".", "//")
if os.path.exists("apps"):
path = os.path.join("apps", app_path)
else:
path = app_path
if os.path.exists(path):
while ans not in ("y", "n"):
ans = raw_input("The app directory has been existed, do you want to overwrite it?(y/n)[n]")
if not ans:
ans = "n"
else:
ans = "y"
if ans == "y":
from uliweb.utils.common import extract_dirs
extract_dirs("uliweb", "template_files/app", path, verbose=global_options.verbose)
示例5: handle
def handle(self, options, global_options, *args):
from uliweb.utils.common import extract_dirs
from uliweb.core.template import template_file
if not args:
project_name = ""
while not project_name:
project_name = raw_input("Please enter project name:")
else:
project_name = args[0]
ans = "-1"
if os.path.exists(project_name):
if options.force:
ans = "y"
while ans not in ("y", "n"):
ans = raw_input("The project directory has been existed, do you want to overwrite it?(y/n)[n]")
if not ans:
ans = "n"
else:
ans = "y"
if ans == "y":
extract_dirs("uliweb", "template_files/project", project_name, verbose=global_options.verbose)
# template setup.py
setup_file = os.path.join(project_name, "setup.py")
text = template_file(setup_file, {"project_name": project_name})
with open(setup_file, "w") as f:
f.write(text)
# rename .gitignore.template to .gitignore
os.rename(os.path.join(project_name, ".gitignore.template"), os.path.join(project_name, ".gitignore"))
示例6: handle
def handle(self, options, global_options, *args):
from uliweb.utils.common import extract_dirs, pkg
from uliweb.core.template import template_file
extract_dirs('uliweb.contrib.orm', 'templates/alembic', '.', verbose=global_options.verbose, replace=False)
engine_string = get_engine(options, global_options)
ini_file = os.path.join(pkg.resource_filename('uliweb.contrib.orm', 'templates/alembic/alembic.ini'))
text = template_file(ini_file, {'CONNECTION':engine_string})
with open(os.path.join(global_options.project, 'alembic.ini'), 'w') as f:
f.write(text)
示例7: handle
def handle(self, options, global_options, *args):
from uliweb.utils.common import extract_dirs
_types = ['gae', 'dotcloud', 'sae', 'bae', 'fcgi', 'heroku', 'tornado', 'gevent', 'gevent-socketio']
support_type = args[0] if args else ''
while not support_type in _types and support_type != 'quit':
print 'Supported types:\n'
print ' ' + '\n '.join(_types)
print
support_type = raw_input('Please enter support type[quit to exit]:')
if support_type != 'quit':
extract_dirs('uliweb', 'template_files/support/%s' % support_type, '.', verbose=global_options.verbose)
示例8: handle
def handle(self, options, global_options, *args):
from uliweb.utils.common import extract_dirs
if not args:
project_name = ''
while not project_name:
project_name = raw_input('Please enter project name:')
else:
project_name = args[0]
ans = '-1'
if os.path.exists(project_name):
while ans not in ('y', 'n'):
ans = raw_input('The project directory has been existed, do you want to overwrite it?(y/n)[n]')
if not ans:
ans = 'n'
else:
ans = 'y'
if ans == 'y':
extract_dirs('uliweb', 'template_files/project', project_name, verbose=global_options.verbose)