Spaces:
Runtime error
Runtime error
DrishtiSharma
commited on
Commit
•
d90fe14
1
Parent(s):
5ba7dcf
Upload reader.py
Browse files
reader.py
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from yattag import Doc
|
3 |
+
|
4 |
+
## --------------------------------- ###
|
5 |
+
### reading: info.txt ###
|
6 |
+
### -------------------------------- ###
|
7 |
+
# placeholders in case info.txt does not exist
|
8 |
+
|
9 |
+
def get_article():
|
10 |
+
filename = "info.txt"
|
11 |
+
placeholder = "please create an info.txt to customize this text"
|
12 |
+
|
13 |
+
title = bkgd = sgd1 = sgd2 = td = limitation = con1 = con2 = con3 = membs = placeholder
|
14 |
+
# check if info.txt is present
|
15 |
+
if os.path.isfile(filename):
|
16 |
+
# open info.txt in read mode
|
17 |
+
info = open(filename, "r")
|
18 |
+
|
19 |
+
# read each line to a string
|
20 |
+
description = info.readline()
|
21 |
+
title = info.readline()
|
22 |
+
bkgd = info.readline()
|
23 |
+
sgd1 = info.readline()
|
24 |
+
sgd2 = info.readline()
|
25 |
+
td = info.readline()
|
26 |
+
limitation = info.readline()
|
27 |
+
con1 = info.readline()
|
28 |
+
con2 = info.readline()
|
29 |
+
con3 = info.readline()
|
30 |
+
membs = info.readline()
|
31 |
+
|
32 |
+
# close file
|
33 |
+
info.close()
|
34 |
+
|
35 |
+
# use yattag library to generate html
|
36 |
+
doc, tag, text, line = Doc().ttl()
|
37 |
+
# create html based on info.txt
|
38 |
+
with tag('div'):
|
39 |
+
with tag('div', klass='my-div'):
|
40 |
+
line('h2', 'Project Background')
|
41 |
+
line('p', bkgd)
|
42 |
+
#with tag('div', klass='my-div'):
|
43 |
+
#line('h2', 'Data Collection')
|
44 |
+
#line('p', sgd1)
|
45 |
+
with tag('div', klass='my-div'):
|
46 |
+
line('h2', 'Targeted SGDs and Potential Applications: ')
|
47 |
+
with tag('ul'):
|
48 |
+
line('li', sgd1)
|
49 |
+
line('li', sgd2)
|
50 |
+
with tag('div', klass='my-div'):
|
51 |
+
line('h2', 'Technical challenges faced during this project:')
|
52 |
+
line('p', td)
|
53 |
+
with tag('div', klass='my-div'):
|
54 |
+
line('h2', 'Limitation of this Project/Gradio Application')
|
55 |
+
line('p', limitation)
|
56 |
+
with tag('div', klass='my-div'):
|
57 |
+
line('h2', 'Conclusion and Future Work:')
|
58 |
+
with tag('ul'):
|
59 |
+
line('li', con1)
|
60 |
+
line('li', con2)
|
61 |
+
line('li', con3)
|
62 |
+
with tag('div', klass='my-div'):
|
63 |
+
line('h2', 'Team Members')
|
64 |
+
line('p', membs)
|
65 |
+
|
66 |
+
|
67 |
+
css = '''
|
68 |
+
.my-div {
|
69 |
+
border: 2px solid black;
|
70 |
+
text-align: center;
|
71 |
+
margin: 10px;
|
72 |
+
padding: 5%;
|
73 |
+
}
|
74 |
+
ul {
|
75 |
+
display: inline-block;
|
76 |
+
text-align: left;
|
77 |
+
}
|
78 |
+
.description {
|
79 |
+
text-align: center;
|
80 |
+
}
|
81 |
+
'''
|
82 |
+
|
83 |
+
return {
|
84 |
+
'article': doc.getvalue(),
|
85 |
+
'css': css,
|
86 |
+
'title': title,
|
87 |
+
'description': description,
|
88 |
+
}
|