From f469963470184776db14c85cc46706ed696e78fc Mon Sep 17 00:00:00 2001 From: zeroth Date: Fri, 24 May 2019 15:59:49 +0100 Subject: [PATCH] the score works finely --- __pycache__/contextualise.cpython-35.pyc | Bin 5475 -> 6097 bytes contextualise.py | 55 +++++++++++++++++++++-- generate_links.py | 7 +-- templates/layout.html | 3 ++ 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/__pycache__/contextualise.cpython-35.pyc b/__pycache__/contextualise.cpython-35.pyc index cea4e4573b4be93e4d9261887b4e3bbca239c020..4f4d91340481e7aba1634e957857a9049f5c2bfd 100644 GIT binary patch delta 2203 zcmaJ?O>7%Q6n?Yozu0TXcAVHHgt!zpb<_OyKj}YBf1qhg8>E8O%33n(WF5!r&TeQL z?aG2yw7nptz2(RSPDs!LCn|9P35i3mE5W4)DkKhE5eMEIvu(JLjlX^W^WK}8x6k%I zo!V7Qr<2pM=Qod30G`3NzXH;y@n`?^^{zja?mY0_z{lV|z&!@Fc`!zxc?S3%VtEz# z-cWTeREU^l0l&UG<)1m4@sG0%3ANT=SW@y9sLEwkbrcMsEi=okB>3;eZ#NeujjK zzq8bUB7y_J8SL|aYwu?zl3sUN40llTNdhG2|<3KVAuWF~lMsO(E57^4J6;@teu5X;6E zitHo;D0!x_96n;f|56K5SIGD>!BzAqlv}3lSdBZD;P&Sz?K!C$%g9Gu^S@6Q`%9>a zFF-+L{q_S051X@F)A?zt^zy?J5aRR2jbh1_u}BF;Ku2E5FLRg28fb` z$KakqLZn?4N*)G@K@+7IHUN<&k#cbm^Ei!-WAb1J6NJ3g8{bG?s zxJVy3eb7vT+ebF+_7k{4$tPv^9zHPKu5ldb@ZvROrs%nq)Us z@HFt!;ANyM#?@XrQ7{aNRj2Wb49mf>O5FIv$Twjxh?x%vN%g3-MJvcnF!1JwS4R{$6P zyIClDgW#s9bClIp1!;E>rT9w0BY@iz%+11f_QpfJ$UXDtiW{MtO5PB-Ltza=vW6j9 zgOtk^k%|Gj7SXVXfq5Dpbs0P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~$D;2Kj0XkbvjShW?VbFY+?>8NVK>iBzurTCkLF!PX%(sP|L+u9_@d~S?@}mnH zI-ai^er3}&^4T9p>xefF1YCs=R6bDK-{EYirxrN12oQZTjeU7)k`8L$~$@-`Ync zdDjUbZEC`U*OpmoiB6H1wy@<(=9iA4F59-{s4U71X;Lyt?P>|VX+}G{#3i%PdAV(t z_3mn$(--Tr`+8n>`r7+0X2icW058!1 diff --git a/contextualise.py b/contextualise.py index f08c96b..ba8e57d 100644 --- a/contextualise.py +++ b/contextualise.py @@ -112,9 +112,10 @@ def functionsession(): return(session) # THIS IS NOT WORKING YET DUNNO WHY -# @app.context_processor -# def context_processor(): -# return dict(functionsession=functionsession) +@app.context_processor +def context_processor(): + functionsession = session['wordpath'] + return dict(functionsession=functionsession) @app.route('/about/') def about(): @@ -182,7 +183,21 @@ def get_file(): idlist = session["id"] timelist = session["clicktime"] veryfirstnow = session['veryfirstnow'] + clickongetfiletime = datetime.now() + tadam = None + initialtime = None + + if not (timelist[0] is None): + thetime = timelist[0] + thetime = str(thetime) + thetime = dt.datetime.strptime(thetime, '%Y-%m-%d %H:%M:%S.%f') + initialtime = thetime - veryfirstnow + initialtime = initialtime.total_seconds() + initialtime = int(initialtime) + initialtime = "."*initialtime + + print(initialtime) for t in timelist : t = str(t) @@ -192,7 +207,16 @@ def get_file(): prev = None wholestringy = None + print("veryfirstnow : "+str(veryfirstnow)+"\n") + + + for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist): + print("word : "+word+"\n") + print("timeofclick : "+str(time)+"\n") + print("============") + print(wordpath) + print("============") filler = int(uniqueid) upperword = word.upper() @@ -225,18 +249,41 @@ def get_file(): fullscore = wholestringy - #If fullscore length superior 60 characters, insert linebreak + # #If fullscore length superior 60 characters, insert linebreak + + # # Defining splitting point + # n = 60 + # # Using list comprehension + # out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)] + # #joining the strings with linebreaks + # tadam = '\n'.join(out) + + if not (fullscore is None): + # outside of the loop calculate seconds from "clickongetfiletime" minus the last "time" from the loop + lastdifftime = clickongetfiletime - prev + lastdifftime = lastdifftime.total_seconds() + lastdifftime = int(lastdifftime) + lastdifftime = lastdifftime * '.' + #the 60 seconds thing + # print(lastdifftime+"\n") + fullscore = initialtime+fullscore+lastdifftime # Defining splitting point n = 60 # Using list comprehension out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)] #joining the strings with linebreaks tadam = '\n'.join(out) + + + # have a message in file if no nav has been recorded so it's less dull than error page if tadam is None: tadam = "This score is Null" + # print("verylastnow : "+str(clickongetfilefime)+"\n") + + print(tadam) return Response(tadam, diff --git a/generate_links.py b/generate_links.py index ee86ca7..c39fd89 100644 --- a/generate_links.py +++ b/generate_links.py @@ -4,16 +4,17 @@ import re with open('wordlist.json', 'r') as f: wordlist_dict = json.load(f) - +#goes through every single file ending in html +# path = "static/files/" for path, subdirs, files in os.walk(path): for name in files: if name.endswith('html'): file = os.path.join(path, name) - with open(file, 'r+') as f: + with open(file, 'r+', encoding="utf-8") as f: textfile = f.read() for word in wordlist_dict: - # word = re.escape(word) + word = re.escape(word) textfile = re.sub(r"(?\1", textfile) f.truncate(0) f.write(textfile) diff --git a/templates/layout.html b/templates/layout.html index fb9e22d..7565c41 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -26,6 +26,9 @@ +
+ {{ functionsession }} +
{% block content %} {% endblock content %}