def findT(application_path, language='en-us'): """ must be run by the admin app """ path = application_path try: sentences = read_dict(os.path.join(path, 'languages', '%s.py' % language)) except: sentences = {} mp = os.path.join(path, 'models') cp = os.path.join(path, 'controllers') vp = os.path.join(path, 'views') for file in listdir(mp, '.+\.py', 0) + listdir(cp, '.+\.py', 0)\ + listdir(vp, '.+\.html', 0): data = open(file, 'r').read() items = regex_translate.findall(data) for item in items: try: msg = eval(item) if msg and not sentences.has_key(msg): sentences[msg] = '*** %s' % msg except: pass keys = sorted(sentences) file = open(os.path.join(path, 'languages', '%s.py' % language), 'w') file.write('{\n') for key in keys: file.write('%s:%s,\n' % (repr(key), repr(str(sentences[key])))) file.write('}\n') file.close()
def findT(path, language="en-us"): """ must be run by the admin app """ filename = os.path.join(path, "languages", "%s.py" % language) sentences = read_dict(filename) mp = os.path.join(path, "models") cp = os.path.join(path, "controllers") vp = os.path.join(path, "views") for file in listdir(mp, ".+\.py", 0) + listdir(cp, ".+\.py", 0) + listdir(vp, ".+\.html", 0): fp = open(file, "r") portalocker.lock(fp, portalocker.LOCK_SH) data = fp.read() portalocker.unlock(fp) fp.close() items = regex_translate.findall(data) for item in items: try: message = eval(item) if not message.startswith("#") and not "\n" in message: tokens = message.rsplit("##", 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip() + "##" + tokens[1].strip() if message and not message in sentences: sentences[message] = message except: pass write_dict(filename, sentences)
def findT(path, language='en-us'): """ must be run by the admin app """ filename = os.path.join(path, 'languages', '%s.py' % language) sentences = read_dict(filename) mp = os.path.join(path, 'models') cp = os.path.join(path, 'controllers') vp = os.path.join(path, 'views') for file in listdir(mp, '.+\.py', 0) + listdir(cp, '.+\.py', 0)\ + listdir(vp, '.+\.html', 0): fp = open(file, 'r') portalocker.lock(fp, portalocker.LOCK_SH) data = fp.read() portalocker.unlock(fp) fp.close() items = regex_translate.findall(data) for item in items: try: msg = eval(item) if msg and not msg in sentences: sentences[msg] = msg except: pass write_dict(filename, sentences)
def run_models_in(environment): """ Runs all models (in the app specified by the current folder) It tries pre-compiled models first before compiling them. """ folder = environment['request'].folder c = environment['request'].controller f = environment['request'].function cpath = os.path.join(folder, 'compiled') if os.path.exists(cpath): for model in listdir(cpath, '^models_\w+\.pyc$', 0): restricted(read_pyc(model), environment, layer=model) path = os.path.join(cpath, 'models') models = listdir(path, '^\w+\.pyc$',0,sort=False) compiled=True else: path = os.path.join(folder, 'models') models = listdir(path, '^\w+\.py$',0,sort=False) compiled=False paths = (path, os.path.join(path,c), os.path.join(path,c,f)) for model in models: if not os.path.split(model)[0] in paths and c!='appadmin': continue elif compiled: code = read_pyc(model) elif is_gae: code = getcfs(model, model, lambda: compile2(read_file(model), model)) else: code = getcfs(model, model, None) restricted(code, environment, layer=model)
def findT(path, language='en-us'): """ must be run by the admin app """ filename = os.path.join(path, 'languages', '%s.py' % language) sentences = read_dict(filename) mp = os.path.join(path, 'models') cp = os.path.join(path, 'controllers') vp = os.path.join(path, 'views') for file in listdir(mp, '.+\.py', 0) + listdir(cp, '.+\.py', 0)\ + listdir(vp, '.+\.html', 0): fp = open(file, 'r') portalocker.lock(fp, portalocker.LOCK_SH) data = fp.read() portalocker.unlock(fp) fp.close() items = regex_translate.findall(data) for item in items: try: message = eval(item) if not message.startswith('#') and not '\n' in message: tokens = message.rsplit('##', 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip() + '##' + tokens[1].strip() if message and not message in sentences: sentences[message] = message except: pass write_dict(filename, sentences)
def run_models_in(environment): """ Runs all models (in the app specified by the current folder) It tries pre-compiled models first before compiling them. """ folder = environment["request"].folder c = environment["request"].controller f = environment["request"].function cpath = pjoin(folder, "compiled") if os.path.exists(cpath): for model in listdir(cpath, "^models_\w+\.pyc$", 0): restricted(read_pyc(model), environment, layer=model) path = pjoin(cpath, "models") models = listdir(path, "^\w+\.pyc$", 0, sort=False) compiled = True else: path = pjoin(folder, "models") models = listdir(path, "^\w+\.py$", 0, sort=False) compiled = False n = len(path) + 1 for model in models: regex = environment["response"].models_to_run if isinstance(regex, list): regex = re_compile("|".join(regex)) file = model[n:].replace(os.path.sep, "/").replace(".pyc", ".py") if not regex.search(file) and c != "appadmin": continue elif compiled: code = read_pyc(model) elif is_gae: code = getcfs(model, model, lambda: compile2(read_file(model), model)) else: code = getcfs(model, model, None) restricted(code, environment, layer=model)
def read_possible_plurals(): """ create list of all possible plural rules files result is cached to increase speed """ global pcache pdir = abspath('gluon','contrib','rules') plurals = {} # scan rules directory for plural_rules-*.py files: for pname in [f for f in listdir(pdir, regex_plural_rules) if osep not in f]: lang=pname[13:-3] fname=ospath.join(pdir, pname) mtime=ostat(fname).st_mtime if lang in pcache and pcache[lang][2] == mtime: # if plural_file's mtime wasn't changed - use previous value: plurals[lang]=pcache[lang] else: # otherwise, reread plural_rules-file: if 'plural_rules-'+lang in cfs: n,f1,f2,status=read_plural_rules(lang) else: n,f1,f2,status=read_plural_rules_aux(fname) plurals[lang]=(n, pname, mtime, status) pcache=plurals return pcache
def compile_controllers(folder): """ compiles all the controllers in the applicaiton specified by the current folder """ path = os.path.join(folder, "controllers/") for file in listdir(path, ".+\.py$"): save_pyc(os.path.join(path, file)) data = open(path + file, "r").read() exposed = regex_expose.findall(data) for function in exposed: command = ( data + """ response._vars=response._caller(%s)""" % function ) filename = os.path.join( folder, "compiled/", ("controllers/" + file[:-3]).replace("/", "_") + "_" + function + ".py" ) open(filename, "w").write(command) save_pyc(filename) os.unlink(filename)
def read_possible_languages_aux(langdir): langs = {} # scan languages directory for langfiles: for langfile in [f for f in listdir(langdir, regex_langfile) + listdir(langdir, '^default\.py$') if osep not in f]: lang=langfile[:-3] langs[lang]=get_lang_info(lang, langdir) if 'default' not in langs: # if default.py is not found, add default value: langs['default'] = ('en', 'English', 0) deflang=langs['default'] if deflang[0] not in langs: # create language from default.py: langs[deflang[0]] = (deflang[0], deflang[1], 0) return langs
def remove_compiled_application(folder): """ Deletes the folder `compiled` containing the compiled application. """ try: shutil.rmtree(pjoin(folder, 'compiled')) path = pjoin(folder, 'controllers') for file in listdir(path, '.*\.pyc$', drop=False): os.unlink(file) except OSError: pass
def remove_compiled_application(folder): try: path = os.path.join(folder, "compiled/") for file in listdir(path): os.unlink(os.path.join(path, file)) os.rmdir(path) path = os.path.join(folder, "controllers/") for file in os.listdir(path): if file.endswith(".pyc"): os.unlink(os.path.join(path, file)) except OSError: pass
def compile_models(folder): """ compiles all the models in the applicaiton specified by the current folder """ path = os.path.join(folder, "models/") for file in listdir(path, ".+\.py$"): data = open(os.path.join(path, file), "r").read() filename = os.path.join(folder, "compiled/", ("models/" + file).replace("/", "_")) open(filename, "w").write(data) save_pyc(filename) os.unlink(filename)
def run_models_in(environment): """ runs all models (in the app specified by the current folder) in the environment. it tries precompiled models first. """ folder = environment["request"].folder path = os.path.join(folder, "compiled/") if os.path.exists(path): for model in listdir(path, "^models_.+\.pyc$", 0): restricted(read_pyc(model), environment, layer=model) else: models = listdir(os.path.join(folder, "models/"), "^\w+\.py$", 0) for model in models: layer = model if is_gae: code = getcfs( model, model, lambda: compile(open(model, "r").read().replace("\r\n", "\n"), layer, "exec") ) else: code = getcfs(model, model, None) restricted(code, environment, layer)
def findT(path, language=DEFAULT_LANGUAGE): """ must be run by the admin app """ lang_file = pjoin(path, "languages", language + ".py") sentences = read_dict(lang_file) mp = pjoin(path, "models") cp = pjoin(path, "controllers") vp = pjoin(path, "views") mop = pjoin(path, "modules") for filename in ( listdir(mp, "^.+\.py$", 0) + listdir(cp, "^.+\.py$", 0) + listdir(vp, "^.+\.html$", 0) + listdir(mop, "^.+\.py$", 0) ): data = portalocker.read_locked(filename) items = regex_translate.findall(data) for item in items: try: message = safe_eval(item) except: continue # silently ignore inproperly formatted strings if not message.startswith("#") and not "\n" in message: tokens = message.rsplit("##", 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip() + "##" + tokens[1].strip() if message and not message in sentences: sentences[message] = message if not "!langcode!" in sentences: sentences["!langcode!"] = DEFAULT_LANGUAGE if language in ("default", DEFAULT_LANGUAGE) else language if not "!langname!" in sentences: sentences["!langname!"] = ( DEFAULT_LANGUAGE_NAME if language in ("default", DEFAULT_LANGUAGE) else sentences["!langcode!"] ) write_dict(lang_file, sentences)
def run_models_in(environment): """ Runs all models (in the app specified by the current folder) It tries pre-compiled models first before compiling them. """ folder = environment['request'].folder path = os.path.join(folder, 'compiled') if os.path.exists(path): for model in listdir(path, '^models_.+\.pyc$', 0): restricted(read_pyc(model), environment, layer=model) else: models = listdir(os.path.join(folder, 'models'), '^\w+\.py$', 0) for model in models: layer = model if is_gae: code = getcfs(model, model, lambda: compile2(open(model, 'r').read(),layer)) else: code = getcfs(model, model, None) restricted(code, environment, layer)
def compile_views(folder): """ Compiles all the views in the application specified by `folder` """ path = pjoin(folder, "views") for file in listdir(path, "^[\w/\-]+(\.\w+)+$"): data = parse_template(file, path) filename = ("views/%s.py" % file).replace("/", "_").replace("\\", "_") filename = pjoin(folder, "compiled", filename) write_file(filename, data) save_pyc(filename) os.unlink(filename)
def compile_views(folder): """ Compiles all the views in the application specified by `folder` """ path = pjoin(folder, 'views') for file in listdir(path, '^[\w/\-]+(\.\w+)+$'): data = parse_template(file, path) filename = ('views/%s.py' % file).replace('/', '_').replace('\\', '_') filename = pjoin(folder, 'compiled', filename) write_file(filename, data) save_pyc(filename) os.unlink(filename)
def compile_models(folder): """ Compiles all the models in the application specified by `folder` """ path = pjoin(folder, 'models') for file in listdir(path, '.+\.py$'): data = read_file(pjoin(path, file)) filename = pjoin(folder, 'compiled', 'models', file) mktree(filename) write_file(filename, data) save_pyc(filename) os.unlink(filename)
def app_cleanup(app, request): """ Removes session, cache and error files Parameters ---------- app: application name request: the global request object """ r = True # Remove error files files = listdir(apath('%s/errors/' % app, request), '^\d.*$', 0) for f in files: try: os.unlink(f) except: r = False # Remove session files files = listdir(apath('%s/sessions/' % app, request), '^\d.*$', 0) for f in files: try: os.unlink(f) except: r = False # Remove cache files files = listdir(apath('%s/cache/' % app, request), '^cache.*$', 0) for file in files: try: os.unlink(file) except: r = False return r
def findT(path, language='en'): """ must be run by the admin app """ lang_file = ospath.join(path, 'languages', language + '.py') sentences = read_dict(lang_file) mp = ospath.join(path, 'models') cp = ospath.join(path, 'controllers') vp = ospath.join(path, 'views') mop = ospath.join(path, 'modules') for filename in \ listdir(mp, '^.+\.py$', 0)+listdir(cp, '^.+\.py$', 0)\ +listdir(vp, '^.+\.html$', 0)+listdir(mop, '^.+\.py$', 0): data = portalocker.read_locked(filename) items = regex_translate.findall(data) for item in items: try: message = safe_eval(item) except: continue # silently ignore inproperly formatted strings if not message.startswith('#') and not '\n' in message: tokens = message.rsplit('##', 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip()+'##'+tokens[1].strip() if message and not message in sentences: sentences[message] = message if not '!langcode!' in sentences: sentences['!langcode!'] = ( 'en' if language in ('default', 'en') else language) if not '!langname!' in sentences: sentences['!langname!'] = ( 'English' if language in ('default', 'en') else sentences['!langcode!']) write_dict(lang_file, sentences)
def findT(path, language=DEFAULT_LANGUAGE): """ must be run by the admin app """ lang_file = pjoin(path, 'languages', language + '.py') sentences = read_dict(lang_file) mp = pjoin(path, 'models') cp = pjoin(path, 'controllers') vp = pjoin(path, 'views') mop = pjoin(path, 'modules') for filename in \ listdir(mp, '^.+\.py$', 0)+listdir(cp, '^.+\.py$', 0)\ +listdir(vp, '^.+\.html$', 0)+listdir(mop, '^.+\.py$', 0): data = portalocker.read_locked(filename) items = regex_translate.findall(data) for item in items: try: message = safe_eval(item) except: continue # silently ignore inproperly formatted strings if not message.startswith('#') and not '\n' in message: tokens = message.rsplit('##', 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip() + '##' + tokens[1].strip() if message and not message in sentences: sentences[message] = message if not '!langcode!' in sentences: sentences['!langcode!'] = (DEFAULT_LANGUAGE if language in ('default', DEFAULT_LANGUAGE) else language) if not '!langname!' in sentences: sentences['!langname!'] = (DEFAULT_LANGUAGE_NAME if language in ( 'default', DEFAULT_LANGUAGE) else sentences['!langcode!']) write_dict(lang_file, sentences)
def findT(path, language='en'): """ must be run by the admin app """ filename = ospath.join(path, 'languages', language + '.py') sentences = read_dict(filename) mp = ospath.join(path, 'models') cp = ospath.join(path, 'controllers') vp = ospath.join(path, 'views') mop = ospath.join(path, 'modules') for file in listdir(mp, '^.+\.py$', 0) + listdir(cp, '^.+\.py$', 0)\ + listdir(vp, '^.+\.html$', 0) + listdir(mop, '^.+\.py$', 0): fp = portalocker.LockedFile(file, 'r') data = fp.read() fp.close() items = regex_translate.findall(data) for item in items: try: message = eval(item) if not message.startswith('#') and not '\n' in message: tokens = message.rsplit('##', 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip() + '##' + tokens[1].strip() if message and not message in sentences: sentences[message] = message except: pass if not '!langcode!' in sentences: sentences['!langcode!'] = ('en' if language in ('default', 'en') else language) if not '!langname!' in sentences: sentences['!langname!'] = ('English' if language in ('default', 'en') else sentences['!langcode!']) write_dict(filename, sentences)
def findT(path, language='en'): """ must be run by the admin app """ filename = ospath.join(path, 'languages', language + '.py') sentences = read_dict(filename) mp = ospath.join(path, 'models') cp = ospath.join(path, 'controllers') vp = ospath.join(path, 'views') mop = ospath.join(path, 'modules') for file in listdir(mp, '^.+\.py$', 0) + listdir(cp, '^.+\.py$', 0)\ + listdir(vp, '^.+\.html$', 0) + listdir(mop, '^.+\.py$', 0): fp = portalocker.LockedFile(file, 'r') data = fp.read() fp.close() items = regex_translate.findall(data) for item in items: try: message = eval(item) if not message.startswith('#') and not '\n' in message: tokens = message.rsplit('##', 1) else: # this allows markmin syntax in translations tokens = [message] if len(tokens) == 2: message = tokens[0].strip() + '##' + tokens[1].strip() if message and not message in sentences: sentences[message] = message except: pass if not '!langcode!' in sentences: sentences['!langcode!'] = ( 'en' if language in ('default', 'en') else language) if not '!langname!' in sentences: sentences['!langname!'] = ( 'English' if language in ('default', 'en') else sentences['!langcode!']) write_dict(filename, sentences)
def remove_compiled_application(folder): """ Deletes the folder `compiled` containing the compiled application. """ try: path = os.path.join(folder, 'compiled/') for file in listdir(path): os.unlink(os.path.join(path, file)) os.rmdir(path) path = os.path.join(folder, 'controllers/') for file in os.listdir(path): if file.endswith('.pyc'): os.unlink(os.path.join(path, file)) except OSError: pass
def compile_views(folder): """ Compiles all the views in the application specified by `folder` """ path = os.path.join(folder, 'views') for file in listdir(path, '^[\w/]+\.\w+$'): data = parse_template(file, path) filename = ('views/%s.py' % file).replace('/', '_').replace('\\', '_') filename = os.path.join(folder, 'compiled', filename) fp = open(filename, 'w') fp.write(data) fp.close() save_pyc(filename) os.unlink(filename)
def compile_views(folder): """ Compiles all the views in the application specified by `folder` """ path = os.path.join(folder, 'views/') for file in listdir(path, '^[\w/]+\.\w+$'): data = parse_template(file, path) filename = ('views/%s.py' % file).replace('/', '_').replace('\\', '_') filename = os.path.join(folder, 'compiled', filename) fp = open(filename, 'w') fp.write(data) fp.close() save_pyc(filename) os.unlink(filename)
def compile_views(folder): """ compiles all the views in the applicaiton specified by the current folder """ path = os.path.join(folder, "views/") for file in listdir(path, ".+\.html$"): data = parse_template(file, path) filename = os.path.join( folder, "compiled/", ("views/" + file[:-5] + ".py").replace("/", "_").replace("\\", "_") ) open(filename, "w").write(data) save_pyc(filename) os.unlink(filename)
def compile_views(folder): """ compiles all the views in the applicaiton specified by the current folder """ path = os.path.join(folder, 'views/') for file in listdir(path, '.+\.html$'): data = parse_template(file, path) filename = os.path.join(folder, 'compiled/', ('views/' + file[:-5] + '.py').replace( '/', '_').replace('\\', '_')) open(filename, 'w').write(data) save_pyc(filename) os.unlink(filename)
def remove_compiled_application(folder): """ Deletes the folder `compiled` containing the compiled application. """ try: path = os.path.join(folder, 'compiled') for file in listdir(path): os.unlink(os.path.join(path, file)) os.rmdir(path) path = os.path.join(folder, 'controllers') for file in os.listdir(path): if file.endswith('.pyc'): os.unlink(os.path.join(path, file)) except OSError: pass
def run_models_in(environment): """ Runs all models (in the app specified by the current folder) It tries pre-compiled models first before compiling them. """ folder = environment['request'].folder path = os.path.join(folder, 'compiled/') if os.path.exists(path): for model in listdir(path, '^models_.+\.pyc$', 0): restricted(read_pyc(model), environment, layer=model) else: models = listdir(os.path.join(folder, 'models/'), '^\w+\.py$', 0) for model in models: layer = model if is_gae: code = getcfs(model, model, lambda: \ compile(open(model, 'r')\ .read().replace('\r\n', '\n'), layer, 'exec')) else: code = getcfs(model, model, None) restricted(code, environment, layer)
def run_models_in(environment): """ Runs all models (in the app specified by the current folder) It tries pre-compiled models first before compiling them. """ folder = environment['request'].folder c = environment['request'].controller f = environment['request'].function cpath = pjoin(folder, 'compiled') if os.path.exists(cpath): for model in listdir(cpath, '^models_\w+\.pyc$', 0): restricted(read_pyc(model), environment, layer=model) path = pjoin(cpath, 'models') models = listdir(path, '^\w+\.pyc$', 0) compiled = True else: path = pjoin(folder, 'models') models = listdir(path, '^\w+\.py$', 0) compiled = False n = len(path) + 1 for model in models: regex = environment['response'].models_to_run if isinstance(regex, list): regex = re_compile('|'.join(regex)) file = model[n:].replace(os.path.sep, '/').replace('.pyc', '.py') if not regex.search(file) and c != 'appadmin': continue elif compiled: code = read_pyc(model) elif is_gae: code = getcfs(model, model, lambda: compile2(read_file(model), model)) else: code = getcfs(model, model, None) restricted(code, environment, layer=model)
def run_models_in(environment): """ Runs all models (in the app specified by the current folder) It tries pre-compiled models first before compiling them. """ folder = environment['request'].folder c = environment['request'].controller f = environment['request'].function cpath = pjoin(folder, 'compiled') if os.path.exists(cpath): for model in listdir(cpath, '^models_\w+\.pyc$', 0): restricted(read_pyc(model), environment, layer=model) path = pjoin(cpath, 'models') models = listdir(path, '^\w+\.pyc$',0,sort=False) compiled=True else: path = pjoin(folder, 'models') models = listdir(path, '^\w+\.py$',0,sort=False) compiled=False n = len(path) + 1 for model in models: regex = environment['response'].models_to_run if isinstance(regex, list): regex = re_compile('|'.join(regex)) file = model[n:].replace(os.path.sep, '/').replace('.pyc', '.py') if not regex.search(file) and c!= 'appadmin': continue elif compiled: code = read_pyc(model) elif is_gae: code = getcfs(model, model, lambda: compile2(read_file(model), model)) else: code = getcfs(model, model, None) restricted(code, environment, layer=model)
def findT(path, language="en-us"): """ must be run by the admin app """ filename = os.path.join(path, "languages", "%s.py" % language) sentences = read_dict(filename) mp = os.path.join(path, "models") cp = os.path.join(path, "controllers") vp = os.path.join(path, "views") for file in listdir(mp, ".+\.py", 0) + listdir(cp, ".+\.py", 0) + listdir(vp, ".+\.html", 0): fp = open(file, "r") portalocker.lock(fp, portalocker.LOCK_SH) data = fp.read() portalocker.unlock(fp) fp.close() items = regex_translate.findall(data) for item in items: try: msg = eval(item) if msg and not msg in sentences: sentences[msg] = msg except: pass write_dict(filename, sentences)
def compile_views(folder): """ Compiles all the views in the application specified by `folder` """ path = pjoin(folder, 'views') for file in listdir(path, '^[\w/\-]+(\.\w+)*$'): try: data = parse_template(file, path) except Exception, e: raise Exception("%s in %s" % (e, file)) filename = ('views/%s.py' % file).replace('/', '_').replace('\\', '_') filename = pjoin(folder, 'compiled', filename) write_file(filename, data) save_pyc(filename) os.unlink(filename)
def compile_models(folder): """ Compiles all the models in the application specified by `folder` """ path = os.path.join(folder, 'models') for file in listdir(path, '.+\.py$'): fp = open(os.path.join(path, file), 'r') data = fp.read() fp.close() filename = os.path.join(folder, 'compiled', ('models/' + file).replace('/', '_')) fp = open(filename, 'w') fp.write(data) fp.close() save_pyc(filename) os.unlink(filename)
def compile_models(folder): """ Compiles all the models in the application specified by `folder` """ path = os.path.join(folder, 'models/') for file in listdir(path, '.+\.py$'): fp = open(os.path.join(path, file), 'r') data = fp.read() fp.close() filename = os.path.join(folder, 'compiled/', ('models/' + file).replace('/', '_')) fp = open(filename, 'w') fp.write(data) fp.close() save_pyc(filename) os.unlink(filename)
def compile_controllers(folder): """ Compiles all the controllers in the application specified by `folder` """ path = pjoin(folder, "controllers") for file in listdir(path, ".+\.py$"): ### why is this here? save_pyc(pjoin(path, file)) data = read_file(pjoin(path, file)) exposed = regex_expose.findall(data) for function in exposed: command = data + "\nresponse._vars=response._caller(%s)\n" % function filename = pjoin( folder, "compiled", ("controllers/" + file[:-3]).replace("/", "_") + "_" + function + ".py" ) write_file(filename, command) save_pyc(filename) os.unlink(filename)
def compile_controllers(folder): """ Compiles all the controllers in the application specified by `folder` """ path = pjoin(folder, 'controllers') for file in listdir(path, '.+\.py$'): ### why is this here? save_pyc(pjoin(path, file)) data = read_file(pjoin(path, file)) exposed = regex_expose.findall(data) for function in exposed: command = data + "\nresponse._vars=response._caller(%s)\n" % \ function filename = pjoin(folder, 'compiled', ('controllers/' + file[:-3]).replace('/', '_') + '_' + function + '.py') write_file(filename, command) save_pyc(filename) os.unlink(filename)
def compile_controllers(folder): """ Compiles all the controllers in the application specified by `folder` """ path = pjoin(folder, 'controllers') for file in listdir(path, '.+\.py$'): ### why is this here? save_pyc(pjoin(path, file)) data = read_file(pjoin(path,file)) exposed = regex_expose.findall(data) for function in exposed: command = data + "\nresponse._vars=response._caller(%s)\n" % \ function filename = pjoin(folder, 'compiled', ('controllers/' + file[:-3]).replace('/', '_') + '_' + function + '.py') write_file(filename, command) save_pyc(filename) os.unlink(filename)
def compile_controllers(folder): """ Compiles all the controllers in the application specified by `folder` """ path = os.path.join(folder, 'controllers/') for file in listdir(path, '.+\.py$'): save_pyc(os.path.join(path, file)) fp = open(path + file, 'r') data = fp.read() fp.close() exposed = regex_expose.findall(data) for function in exposed: command = data + "\nresponse._vars=response._caller(%s)\n" % \ function filename = os.path.join(folder, 'compiled/', ('controllers/' + file[:-3]).replace('/', '_') + '_' + function + '.py') fp = open(filename, 'w') fp.write(command) fp.close() save_pyc(filename) os.unlink(filename)
def compile_controllers(folder): """ compiles all the controllers in the applicaiton specified by the current folder """ path = os.path.join(folder, 'controllers/') for file in listdir(path, '.+\.py$'): save_pyc(os.path.join(path, file)) data = open(path + file, 'r').read() exposed = regex_expose.findall(data) for function in exposed: command = data + ''' response._vars=response._caller(%s)'''\ % function filename = os.path.join( folder, 'compiled/', ('controllers/' + file[:-3]).replace('/', '_') + '_' + function + '.py') open(filename, 'w').write(command) save_pyc(filename) os.unlink(filename)
def update_all_languages(application_path): path = ospath.join(application_path, 'languages/') for language in listdir(path, regex_langfile): findT(application_path, language[:-3])
def update_all_languages(application_path): path = os.path.join(application_path, 'languages/') for language in listdir(path, '^\w+(\-\w+)?\.py$'): findT(application_path, language[:-3])