#!/usr/bin/env python # -*- coding: utf-8 -*- """ __title__ = '平台配置操作工具类' @Time : 2020/9/26 21:51 @Author : Kenny-PC @Software: PyCharm # code is far away from bugs with the god animal protecting I love animals. They taste delicious. ┏┓ ┏┓ ┏┛┻━━━┛┻┓ ┃ ☃ ┃ ┃ ┳┛ ┗┳ ┃ ┃ ┻ ┃ ┗━┓ ┏━┛ ┃ ┗━━━┓ ┃ 神兽保佑 ┣┓ ┃ 永无BUG! ┏┛ ┗┓┓┏━┳┓┏┛ ┃┫┫ ┃┫┫ ┗┻┛ ┗┻┛ """ import os import time import pandas as pd # 得到当前文件的父目录 parent_dir_path = os.path.dirname(os.path.abspath('.')) def get_yuewen_account_list(): """ description: 阅文账号列表 return: [['email', 'appsecert']] ->list """ return get_account_list('阅文', 'yuewen_account_config.csv') def get_zhangdu_account_list(): """ description: 掌读账号列表 return: [['uid', 'appsecert', 'channel']] ->list """ return get_account_list('掌读', 'zhangdu_account_config.csv') def get_huasheng_account_list(): """ description: 花生账号列表 return: [['apiKey', 'apiSecurity', 'stage']] ->list """ return get_account_list('花生', 'huasheng_account_config.csv') def get_zhangzhongyun_account_list(): """ description: 掌中云账号列表 return: [['key', 'secert', 'stage']] ->list """ return get_account_list('掌中云', 'zhangzhongyun_account_config.csv') def get_youshuge_account_list(): """ description: 悠书阁账号列表 return: [['host_name', 'channel_id', 'secert_key', 'channel', 'stage']] ->list """ return get_account_list('悠书阁', 'youshuge_account_config.csv') def get_account_list(platform, account_file_name): """ description: 读取账号列表 return: [['value1_1', 'value1_3'...]...] ->list """ # print(parent_dir_path) file_path = parent_dir_path + "/tests/conf/account/" + account_file_name # print(file_path) data = pd.read_csv(file_path, header=None, keep_default_na=False, encoding='utf8') account = [] for i in data.index: account.append(list(data.values[i])) account_list = list(account) # 若想用二维列表的形式读取即删掉此行语句 print('读取到【{platform}】账号数量【{quantity}】个'.format(platform=platform, quantity=len(account_list))) return account_list def get_zhangzhongyun_format_time(st_unix): """ description: 掌中云的时间格式比较特殊,需要转换下 return: 2020-09-25T00:00:00+08:00 -> str """ return time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(st_unix)) + '+08:00'