-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrelease_prots.py
58 lines (40 loc) · 1.49 KB
/
release_prots.py
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
# These are release prototypes, a good view of what you can expect in the coming release(s)
# See the history for previous prototypes.
# 1/1 implemented
# 2/2 todo
# In memory storage of HTML and CSS files.
# Right now, an `index.html` and `style.css` is created in the working directory when Sierra's title() is executed.
# In-mem storage uses StringIO to save the contents of `index.html` and `style.css` into variables.
# This will be useful when using Sierra with frameworks other than Flask.
# So something like this:
import io
import os
from flask import Flask
def autoPrettify(in_mem=False):
if in_mem is False:
# Auto Prettify's working code
pass
if in_mem == True:
autoPrettify(in_mem=False)
with open("index.html", 'a+') as f:
f.write("\n\n<style>")
styling = open("style.css", 'r').read()
f.write(f"\n{styling}")
f.write("\n\n</style>")
os.remove("style.css")
global index_html
index_html = open("index.html", 'r').read()
index_html = io.StringIO(index_html)
app = Flask(__name__)
@app.route("/some_route")
def some_func():
autoPrettify()
return index_html
# This way, Sierra can also be used with other web frameworks in an easier way.
# This is still just a prototype, yet to test and run.
# Creating tags with decorator
@tag
def label(**kwargs):
pass
label(_class='someClass', _for='someInput')
# See `src/sierra/custom_tags.py` for more