From 33aad7b132970754152c099ee4744dee5687de93 Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Fri, 30 Mar 2018 15:07:18 +0200 Subject: [PATCH] minor changes --- .gitignore | 1 + consume.py | 12 ++++++------ templates/detail.html | 6 +++--- text_generator.py | 4 ++-- todb.py | 7 ++++++- web/static/sass/style.scss | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index a1d831b..aa8219b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ sites raw downloads +chains word-rnn-tensorflow/ .idea/ __pycache__/ diff --git a/consume.py b/consume.py index 9c96343..c6cb993 100644 --- a/consume.py +++ b/consume.py @@ -12,7 +12,7 @@ files = get_files() # TODO: name sites/id after real url -for file in glob.glob("downloads/**/*.7z"): +for file in glob.glob("downloads/**/*.7z", recursive=True): if "meta" in file: continue filename = os.path.basename(file) @@ -46,8 +46,8 @@ for file in glob.glob("downloads/**/*.7z"): print(code) currentdir = os.getcwd() rawdir = "raw/" + code - sitesdir = "sites/" + code - for dir in [rawdir, sitesdir]: + chainsdir = "chains/" + code + for dir in [rawdir, chainsdir]: if not os.path.exists(dir): os.mkdir(dir) @@ -57,7 +57,7 @@ for file in glob.glob("downloads/**/*.7z"): subprocess.check_output(["7z", "x", "-aoa", code + ".7z"]) os.chdir(currentdir) print("Start parsing") - parse_posts(rawdir, sitesdir) - parse_comments(rawdir, sitesdir) - parse_usernames(rawdir, sitesdir) + parse_posts(rawdir, rawdir) + parse_comments(rawdir, rawdir) + parse_usernames(rawdir, rawdir) print("DONE") diff --git a/templates/detail.html b/templates/detail.html index 6765fd2..4bd7d6e 100644 --- a/templates/detail.html +++ b/templates/detail.html @@ -27,7 +27,7 @@

{{ answers|length }} Answers

{% for answer in answers %} {% set vote=voted[("answer", answer.id)] %} -
+
{{ answer.upvotes - answer.downvotes }}
@@ -38,11 +38,11 @@

{{ paragraph }}

{% endfor %}
diff --git a/text_generator.py b/text_generator.py index 0ebe41e..c10c3ef 100644 --- a/text_generator.py +++ b/text_generator.py @@ -58,8 +58,8 @@ def generate_chain(sourcedir, chainfile, mode): def get_chain(url, mode): - sourcedir = 'sites/{url}'.format(url=url, type=mode) - chainfile = 'sites/{url}/{type}.chain.json'.format(url=url, type=mode) + sourcedir = 'raw/{url}'.format(url=url, type=mode) + chainfile = 'chains/{url}/{type}.chain.json'.format(url=url, type=mode) if os.path.exists(chainfile): return load_chain(chainfile, mode) else: diff --git a/todb.py b/todb.py index 0db1107..4e3a409 100644 --- a/todb.py +++ b/todb.py @@ -1,6 +1,7 @@ import random from datetime import datetime +import sys from slugify import slugify import utils @@ -62,7 +63,11 @@ def add_question(site, count=100): if __name__ == "__main__": - query = Site.select().where(Site.last_download.is_null(False)) + if len(sys.argv) > 1: + sites = sys.argv[1:] + query = Site.select().where((Site.last_download.is_null(False)) & (Site.url.in_(sites))) + else: + query = Site.select().where(Site.last_download.is_null(False)) for s in query: add_username(s) add_title(s) diff --git a/web/static/sass/style.scss b/web/static/sass/style.scss index 68842ac..f2d0fa4 100644 --- a/web/static/sass/style.scss +++ b/web/static/sass/style.scss @@ -51,7 +51,7 @@ pre > code { background: #E1ECF9; font-size: 12px; padding: 5px; - + color: #111; } }