2022-02-03 20:02:38 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -- coding:utf-8 --
|
|
|
|
|
# @Author: markushammered@gmail.com
|
|
|
|
|
# @Development Tool: PyCharm
|
|
|
|
|
# @Create Time: 2022/2/3
|
|
|
|
|
# @File Name: b64img.py
|
|
|
|
|
|
|
|
|
|
|
2022-02-07 17:24:01 +08:00
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def re_sort_number_image(origin_number: str, theme: str) -> list:
|
2022-02-03 20:02:38 +08:00
|
|
|
"""
|
2022-02-04 11:08:34 +08:00
|
|
|
返回一个排列好的svg base64代码列表
|
2022-02-07 17:24:01 +08:00
|
|
|
:param theme:
|
2022-02-04 11:08:34 +08:00
|
|
|
:param origin_number:
|
2022-02-03 20:02:38 +08:00
|
|
|
:return:
|
|
|
|
|
"""
|
2022-02-07 17:24:01 +08:00
|
|
|
if theme == 't1':
|
|
|
|
|
cursor.execute('select * from theme1')
|
|
|
|
|
data = cursor.fetchall()
|
|
|
|
|
elif theme == 't2':
|
|
|
|
|
cursor.execute('select * from theme2')
|
|
|
|
|
data = cursor.fetchall()
|
|
|
|
|
else:
|
|
|
|
|
cursor.execute('select * from theme1')
|
|
|
|
|
data = cursor.fetchall()
|
|
|
|
|
temp_dict = {}
|
|
|
|
|
for k, v in data:
|
|
|
|
|
temp_dict.setdefault(k, []).append(v)
|
|
|
|
|
for i, c in zip(temp_dict.keys(), temp_dict.values()):
|
|
|
|
|
temp_dict[i] = c[0]
|
2022-02-03 20:02:38 +08:00
|
|
|
|
2022-02-04 11:08:34 +08:00
|
|
|
final_b64_img_code = []
|
2022-02-04 11:56:21 +08:00
|
|
|
if origin_number != '0000000000':
|
|
|
|
|
for i in origin_number:
|
2022-02-04 11:58:58 +08:00
|
|
|
if i == '0':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '1':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '2':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '3':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '4':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '5':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '6':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '7':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '8':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:58:58 +08:00
|
|
|
elif i == '9':
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(i)))
|
2022-02-04 11:08:34 +08:00
|
|
|
|
2022-02-04 11:56:21 +08:00
|
|
|
return final_b64_img_code
|
|
|
|
|
else:
|
|
|
|
|
for i in range(10):
|
2022-02-07 17:24:01 +08:00
|
|
|
final_b64_img_code.append(temp_dict.get(str(0)))
|
2022-02-04 11:56:21 +08:00
|
|
|
return final_b64_img_code
|
2022-02-07 17:24:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ != '__main__':
|
|
|
|
|
conn = sqlite3.connect('./bin/res/theme.db')
|
|
|
|
|
cursor = conn.cursor()
|