Commit 84e5ca15 authored by rico_X1's avatar rico_X1
Browse files

initial commit

# v.08APR19
import json
from init import *
class Result:
def __init__(self, ok=None, success_msg=None, error_msg=None, data={}, misc={}):
self.ok = ok
self.success_msg = success_msg
self.error_msg = error_msg = data
self.misc = misc
self.msg = None
def set(self, dataset, strict=True):
if isinstance(dataset, str):
dataset = json.loads(dataset)
if isinstance(dataset, dict):
for k, v in dataset.items():
if strict:
if k in self.__dict__.keys():
setattr(self, k, v)
setattr(self, k ,v)
def process(self):
if self.ok is None:
self.ok = 1 if ( or self.success_msg) else 0
self.msg = self.success_msg if self.ok == 1 else self.error_msg
return self
def json(self):
if not = None
if not self.misc:
self.misc = None
return json.dumps(self.__dict__, cls=C0JsonEncoder)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment