修复bug

This commit is contained in:
MarkusJoe
2022-02-07 22:11:56 +08:00
parent 4479fbb3ea
commit 4f18fdcbdb
21 files changed
+212 -78

No files matched your search

+15 -6
View File
@@ -16,15 +16,24 @@ def re_sort_number_image(origin_number: str, theme: str) -> list:
:param origin_number:
:return:
"""
print(theme)
if theme == 't1':
cursor.execute('select * from theme1')
data = cursor.fetchall()
elif theme == 't2':
cursor.execute('select * from theme2')
data = cursor.fetchall()
elif theme == 'gelbooru':
cursor.execute('select * from gelbooru')
elif theme == 'gelbooru-h':
cursor.execute('select * from gelbooruh')
elif theme == 'moebooru':
cursor.execute('select * from moebooru')
elif theme == 'moebooru-h':
cursor.execute('select * from moebooruh')
elif theme == 'rule34':
cursor.execute('select * from rule34')
else:
cursor.execute('select * from theme1')
data = cursor.fetchall()
cursor.execute('select * from rule34')
data = cursor.fetchall()
temp_dict = {}
for k, v in data:
temp_dict.setdefault(k, []).append(v)
@@ -63,5 +72,5 @@ def re_sort_number_image(origin_number: str, theme: str) -> list:
if __name__ != '__main__':
conn = sqlite3.connect('./bin/res/theme.db')
cursor = conn.cursor()
conn = sqlite3.connect('./bin/assets/theme.db')
cursor = conn.cursor()
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/2/5
# @File Name: length.py
def make_html(length: int, svg_width: int = 45, svg_height: int = 50) -> None:
"""
生成html
:param svg_height:
:param svg_width:
:param length:
:return:
"""
html_head = """<?xml version="1.0" encoding="UTF-8"?>
<svg width="%(w)s" height="%(h)s" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Flask Counter - {{ title }}</title>
<g>\n"""
svg_tag = """ <image x="%(x)s" y="0" width="%(w)s" height="%(h)s" xlink:href="{{ svg_img_%(i)s }}"></image>\n"""
html_feet = """</g></svg>"""
html_head = html_head % {'w': length * svg_width, 'h': svg_height} # 总体宽度
for i in range(length): # 拼接出完整的html
html_head += svg_tag % {'x': i * svg_width, 'w': svg_width, 'h': svg_height, 'i': i}
html_head += html_feet # 加上结尾标签
with open('./templates/index.html', 'w', encoding='utf-8') as template_fp: # 写入文件
template_fp.write(html_head)
+11 -6
View File
@@ -9,18 +9,23 @@
from flask import render_template
def render_temp_(length: int, name: str, image_list: list) -> str:
def render_temp_(length: int, name: str, image_list: list, theme: str) -> str:
"""
代码很烂写到隐蔽的地方就看不见了
:param theme:
:param length:
:param name:
:param image_list:
:return:
"""
if 'gelbooru' in theme:
file_name = f'index{length}-spec.html'
else:
file_name = f'index{length}.html'
# 自己写的都看不下去了
if length == 7:
return render_template('index.html',
return render_template(file_name,
title=name,
svg_img_0=f'{image_list[0]}',
svg_img_1=f'{image_list[1]}',
@@ -31,7 +36,7 @@ def render_temp_(length: int, name: str, image_list: list) -> str:
svg_img_6=f'{image_list[6]}'
)
elif length == 8:
return render_template('index.html',
return render_template(file_name,
title=name,
svg_img_0=f'{image_list[0]}',
svg_img_1=f'{image_list[1]}',
@@ -43,7 +48,7 @@ def render_temp_(length: int, name: str, image_list: list) -> str:
svg_img_7=f'{image_list[7]}'
)
elif length == 9:
return render_template('index.html',
return render_template(file_name,
title=name,
svg_img_0=f'{image_list[0]}',
svg_img_1=f'{image_list[1]}',
@@ -55,8 +60,8 @@ def render_temp_(length: int, name: str, image_list: list) -> str:
svg_img_7=f'{image_list[7]}',
svg_img_8=f'{image_list[8]}',
)
else:
return render_template('index.html',
elif length == 10:
return render_template(file_name,
title=name,
svg_img_0=f'{image_list[0]}',
svg_img_1=f'{image_list[1]}',