def find_template_dir(directory=''): paths = ['templates', '../templates'] if hasattr(sys, 'frozen'): # py2exe modpath = sys.executable else: modpath = __file__ default_locations = [os.path.join(os.path.dirname(modpath), p, directory) for p in paths] if directory: user_locations = [] for user_location in user_path(): user_locations.append(os.path.join(user_location, 'templates', directory)) default_locations = user_locations + default_locations found = False for location in default_locations: template_dir = os.path.normpath(location) if os.path.isdir(template_dir): found = True break if found: return template_dir return False
errno, message = e raise AppError("Can't create a CouchApp in %s: %s" % ( path, message)) for n in DEFAULT_APP_TREE: tp = os.path.join(path, n) os.makedirs(tp) for t in TEMPLATES: appdir = path if prefix: # we do the job twice for now to make sure an app or vendor # template exist in user template location # fast on linux since there is only one user dir location # but could be a little slower on windows for user_location in user_path(): location = os.path.join(user_location, 'templates', prefix, t) if os.path.exists(location): if t == "vendor": vendordir = os.path.join(appdir, "vendor") try: os.makedirs(vendordir) except: pass t = os.path.join(prefix, t) break copy_helper(appdir, t) fid = os.path.join(appdir, '_id') if not os.path.isfile(fid): f = open(fid, 'wb')