Spaces:
Sleeping
Sleeping
File size: 2,064 Bytes
1ce7b5a 7099823 1ce7b5a 7099823 1ce7b5a e5ac914 38c9082 1ce7b5a b76d34c e5ac914 f3d8e10 e5ac914 b76d34c e5ac914 1ce7b5a e5ac914 1ce7b5a b76d34c 1ce7b5a b76d34c 1ce7b5a e5ac914 1ce7b5a f3d8e10 1ce7b5a 7099823 99f08d1 0668caf 3ab7c64 3865414 3ab7c64 38c9082 3ab7c64 99f08d1 1ce7b5a b76d34c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import gradio as gr
import sys,os,io,contextlib
sys.path.append(os.getcwd())
from hpgs import homepg, jsinj
from ogtxt import txt
from ogtxtJ2 import txt as j2
from desptxt import desp, nalz
imgurl='https://raw.githubusercontent.com/picklejar76/kujata-data/master/metadata/makou-reactor/backgrounds/'
imgext='.png'
def gengali(ymgl):
ret=[]
ll=len(ymgl)
for k in range(ll):
y=ymgl[k]
if y.startswith('-'):
y=y[1:]
ymgl[k]=y
yurl=y
else:
yurl=imgurl+y
ret.append((yurl+imgext,y))
return ret
def dtkl(dta):
if len(dta) < 3:
return '[x]'
return dta[1:].replace('\n','<br>')
def psxjp(dta):
ret=['<h1>PSX_JP</h1><br><table border=3>']
ll=len(dta)
for k in range(ll):
ret.append('<tr><td>z'+str(k)+'</td><td>')
ret.append(dtkl(dta[k]))
ret.append('</td></tr>')
ret.append('</table>')
return ret
def tblmaker(ky):
dta=txt[ky]
ddsp=desp[ky]
ll=len(dta)>>1
ret=['<h1>',ddsp,'</h1><br><table border=3>']
for k in range(ll):
ret.append('<tr><td>t'+str(k)+'</td><td>')
ret.append(dtkl(dta[2*k]))
ret.append('</td><td>')
ret.append(dtkl(dta[2*k+1]))
ret.append('</td></tr>')
ret.append('</table>')
if ky in j2:
ret+=psxjp(j2[ky])
return ''.join(ret)
def on_select(data: gr.SelectData):
return tblmaker(data.value['caption'])
def execute_code(code):
try:
exec_globals = {}
output = io.StringIO()
with contextlib.redirect_stdout(output):
exec(code, exec_globals)
return output.getvalue()
except Exception as e:
return str(e)
statement = gr.HTML(homepg[0])
with gr.Blocks(head=jsinj[0], js=jsinj[1]) as demo:
with gr.Row():
statement.render()
for na in nalz:
ymg=na[0]
with gr.Tab(na[1]):
gallery = gr.Gallery(gengali(ymg),columns=4,allow_preview=False)
gallery.select(on_select, None, statement)
katoshit = gr.HTML(homepg[1])
demo.launch(allowed_paths=['.']) |