def init(conf, *args, **opts): if not args: dest = os.getcwd() else: dest = os.path.normpath(os.path.join(os.getcwd(), args[0])) if dest is None: raise AppError('Unknown dest') if opts['empty'] and opts['template']: raise AppError('option "empty" cannot use with "template"') if util.iscouchapp(dest): raise AppError("can't create an app at '{0}'. " "One already exists here.".format(dest)) if util.findcouchapp(dest): raise AppError("can't create an app inside another app '{0}'.".format( util.findcouchapp(dest))) # ``couchapp init -e dest`` if opts['empty']: document(dest, create=True) # ``couchapp init -t template_name dest`` elif opts['template']: generator.init_template(dest, template=opts['template']) # ``couchapp init dest`` else: generator.init_basic(dest) logger.info('{0} created.'.format(dest)) return 0
def startapp(conf, *args, **opts): if len(args) < 1: raise AppError("Can't start an app, name or path is missing") if len(args) == 1: name = args[0] dest = os.path.normpath(os.path.join(os.getcwd(), ".", name)) elif len(args) == 2: name = args[1] dest = os.path.normpath(os.path.join(args[0], name)) if util.iscouchapp(dest): raise AppError("can't create an app at '%s'. " "One already exists here.".format(dest)) if util.findcouchapp(dest): raise AppError("can't create an app inside another app '{0}'.".format(util.findcouchapp(dest))) generator.generate(dest, "startapp", name, **opts) return 0
def __init__(self): self.rc_path = util.rcpath() self.global_conf = self.load(self.rc_path, self.DEFAULTS) self.local_conf = {} self.app_dir = util.findcouchapp(os.getcwd()) if self.app_dir: self.local_conf = self.load_local(self.app_dir) self.conf = self.global_conf.copy() self.conf.update(self.local_conf)