class Matilda(object): def __init__(self,*args,**kwargs): self.storage = get_storage() self.composer = Composer() def is_valid_post(self,post_id): return self.storage.is_valid_post(post_id) def get_post(self, post_id): return self.storage.get_post(post_id) def get_post_id_from_request_data(self, post_data): post_params = json.loads(post_data) return post_params.get("post_id", None) def get_line_data(self,post): if type(post["pub_date"]) != type("abcd"): post["pub_date"] = post["pub_date"].strftime("%Y-%m-%d %H:%M:%S") return json.dumps(post) def edit_post(self, post_data): post = json.loads(post_data) post["pub_date"] = self.get_post(post["post_id"])["pub_date"] return_post = self.storage.edit_post(post,post["post_id"]) self.composer.build_all() return return_post def create_post(self, post_data): post = json.loads(post_data) return_post = self.storage.create_post(post) self.composer.build_all() return return_post
def __init__(self,*args,**kwargs): self.storage = get_storage() self.composer = Composer()
def doCompose(self): fname, _ = QtGui.QFileDialog.getOpenFileName(self, 'Open file', '/home') if fname : Composer.compose(fname) QtCore.QCoreApplication.instance().quit()