def __init__(self, file): self.__conffile = file self.__conffile_bak = '%s%s' % (file, '.new') self.__read_helper = MyFileHelper(self.__conffile) self.__write_helper = MyFileHelper(self.__conffile_bak) self.__all = self.__read_helper.get_all() self.__backends = self.__get_backends() # 保存从文件读出来的backend信息
def __init__(self, file): ''' 客户类构造方法 :param file: 客户信息文件地址 :return: 客户类 ''' self.__helper = MyFileHelper(file) # 初始化文件helper self.__password_col_num = 1 # 定义密码所在的列 self.__status_col_num = 2 # 定义客户状态所在的列 self.__error_count_num = 3 # 定义最多可以操作错误的次数所在的列 self.__balance_col_num = 4 # 定义余额所在的列 self.__error_count_max = conf.error_count_max # 从配置文件读取最多可以输入错误多少次 self.__current_customer_info = {} # 初始化当前用户信息
def __init__(self, file): ''' 构造方法 :param file: 商品信息文件地址 :return: 商品对象 ''' self.__helper = MyFileHelper(file) # 获取商品的文件helper #self.__all_goods = self.__helper.getlist() # 通过调用文件helper的getlist方法获取所有商品 self.__all_goods_list = [] # 初始话所有商品信息的列表,每个元素是一个列表 self.__shopping_cart = [] # 初始化购物车列表 for goods in self.__helper.getlist(): # 遍历商品列表 temp_dict = {} # 定义临时列表 temp_dict['id'] = goods[0] temp_dict['name'] = goods[1] temp_dict['price'] = goods[2] temp_dict['class'] = goods[3] self.__all_goods_list.append(temp_dict) # 将临时字典追加到商品信息中