From cb1cbab430f47cd54a764e0adadea8a71308048b Mon Sep 17 00:00:00 2001 From: Alaa Aqeel Date: Wed, 17 Jan 2018 11:13:47 +0300 Subject: [PATCH] Create Controllers.py --- flask/models/Controllers.py | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 flask/models/Controllers.py diff --git a/flask/models/Controllers.py b/flask/models/Controllers.py new file mode 100644 index 00000000..ef4aff71 --- /dev/null +++ b/flask/models/Controllers.py @@ -0,0 +1,61 @@ +import os,importlib as lib,flask + + +class Controllers(): + + def __init__(self,App): + self.Controll = {} + for i in os.listdir("Controller"): + if not i.startswith("__"): + model = i.strip(".py") + Cl = lib.import_module("Controller.%s"%model,model) + try: + self.Controll.update({model:getattr(Cl,model)(App)}) + except AttributeError: + self.Controll.update({model:Cl}) + + def __getattr__(self,k): + return self.Controll.get(k) + + def __dir__(self): + return self.Controll.keys() + + +class model(): + def __init__(self): + self.moduls = {} + for i in dir(flask): + if not i.startswith("__"): + model = i.strip(".py") + try: + self.moduls.update({model:getattr(flask,model)}) + except: + pass + + def __getattr__(self,k): + return self.moduls.get(k) + + def __dir__(self): + return self.moduls.keys() + + +class Moduls(): + + def __init__(self): + self.moduls = {} + for i in os.listdir("model"): + if not i.startswith("__"): + model = i.strip(".py") + Cl = lib.import_module("model.%s"%model,model) + try: + self.moduls.update({model:getattr(Cl,model)}) + except AttributeError: + self.moduls.update({model:Cl}) + except: + pass + + def __getattr__(self,k): + return self.moduls.get(k) + + def __dir__(self): + return self.moduls.keys()