From 127fa03a738853d76a66f357b6791495a1e8c6e9 Mon Sep 17 00:00:00 2001 From: crunk Date: Sun, 10 Jan 2021 00:07:22 +0100 Subject: [PATCH] potentially stupid book recommendation algorithm --- .../{csvparser/__init__.py => __init.py__} | 0 library/csvparser/__init.py__ | 0 library/csvparser/csvparser.py | 12 +++++- library/library.egg-info/PKG-INFO | 10 +++++ library/library.egg-info/SOURCES.txt | 5 +++ library/library.egg-info/dependency_links.txt | 1 + library/library.egg-info/top_level.txt | 1 + library/rnrfeed/__init.py__ | 0 library/rnrfeed/rnrfeeder.py | 40 +++++++++++++++++++ library/setup.py | 3 ++ library/static/css/style.css | 10 +++-- 11 files changed, 77 insertions(+), 5 deletions(-) rename library/{csvparser/__init__.py => __init.py__} (100%) create mode 100644 library/csvparser/__init.py__ create mode 100644 library/library.egg-info/PKG-INFO create mode 100644 library/library.egg-info/SOURCES.txt create mode 100644 library/library.egg-info/dependency_links.txt create mode 100644 library/library.egg-info/top_level.txt create mode 100644 library/rnrfeed/__init.py__ create mode 100644 library/rnrfeed/rnrfeeder.py create mode 100644 library/setup.py diff --git a/library/csvparser/__init__.py b/library/__init.py__ similarity index 100% rename from library/csvparser/__init__.py rename to library/__init.py__ diff --git a/library/csvparser/__init.py__ b/library/csvparser/__init.py__ new file mode 100644 index 0000000..e69de29 diff --git a/library/csvparser/csvparser.py b/library/csvparser/csvparser.py index 7c91346..e5dc9d9 100644 --- a/library/csvparser/csvparser.py +++ b/library/csvparser/csvparser.py @@ -86,6 +86,17 @@ def getlicenses(): return listoflicenses +def getfieldsofinterest(): + libcsv = open(os.path.join(script_dir, "varlib.csv"), "r") + with libcsv: + csv_as_dict = csv.DictReader(libcsv) + fieldsofinterest = {} + for row in csv_as_dict: + fields = row["Fields"].split(',') + fieldsofinterest[row["Id"]] = fields + return fieldsofinterest + + def getpublicationfromcsvrow(row): year = row["Year"] if not year: @@ -118,7 +129,6 @@ def getpublicationfromcsvrow(row): def getfullpublication(pubid): libcsv = open(os.path.join(script_dir, "varlib.csv"), "r") pubinfo = {} - print(type(pubid)) with libcsv: csv_as_dict = csv.DictReader(libcsv) for row in csv_as_dict: diff --git a/library/library.egg-info/PKG-INFO b/library/library.egg-info/PKG-INFO new file mode 100644 index 0000000..45aab3c --- /dev/null +++ b/library/library.egg-info/PKG-INFO @@ -0,0 +1,10 @@ +Metadata-Version: 1.0 +Name: library +Version: 1.0 +Summary: UNKNOWN +Home-page: UNKNOWN +Author: UNKNOWN +Author-email: UNKNOWN +License: UNKNOWN +Description: UNKNOWN +Platform: UNKNOWN diff --git a/library/library.egg-info/SOURCES.txt b/library/library.egg-info/SOURCES.txt new file mode 100644 index 0000000..754a02f --- /dev/null +++ b/library/library.egg-info/SOURCES.txt @@ -0,0 +1,5 @@ +setup.py +library.egg-info/PKG-INFO +library.egg-info/SOURCES.txt +library.egg-info/dependency_links.txt +library.egg-info/top_level.txt \ No newline at end of file diff --git a/library/library.egg-info/dependency_links.txt b/library/library.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/library/library.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/library/library.egg-info/top_level.txt b/library/library.egg-info/top_level.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/library/library.egg-info/top_level.txt @@ -0,0 +1 @@ + diff --git a/library/rnrfeed/__init.py__ b/library/rnrfeed/__init.py__ new file mode 100644 index 0000000..e69de29 diff --git a/library/rnrfeed/rnrfeeder.py b/library/rnrfeed/rnrfeeder.py new file mode 100644 index 0000000..35405d7 --- /dev/null +++ b/library/rnrfeed/rnrfeeder.py @@ -0,0 +1,40 @@ +from feedparser import parse + +from csvparser.csvparser import getfieldsofinterest, getfullpublication + + +feed = parse("http://varia.zone/en/feeds/all-en.rss.xml") + + +def getentries(): + entries = {} + for entry in feed.entries: + if "Read & Repair" in entry.title: + entries[entry.title] = entry.description + return entries + + +def gettitles(): + titles = [] + for entry in feed.entries: + if "Read & Repair" in entry.title: + titles.append(entry.title) + return titles + + +def rabbithole(): + entries = getentries() + fieldsofinterest = getfieldsofinterest() + for title, entry in entries.items(): + for id, fields in fieldsofinterest.items(): + if [f for f in fields if(f in entry)]: + publicationinfo = getfullpublication(id) + pubtitle = publicationinfo["Title"] + print( + "After {0} we recommend reading {1}".format( + title, + pubtitle) + ) + + +print(rabbithole()) diff --git a/library/setup.py b/library/setup.py new file mode 100644 index 0000000..340f994 --- /dev/null +++ b/library/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup, find_packages + +setup(name='library', version='1.0', packages=find_packages()) diff --git a/library/static/css/style.css b/library/static/css/style.css index 4bed702..5e8a999 100644 --- a/library/static/css/style.css +++ b/library/static/css/style.css @@ -29,7 +29,6 @@ body:after { #varia { line-height: 1.03em; position: relative; - top: 10%; left: 50%; transform: translate(-50%, -50%); color: #FFFFFF; @@ -62,7 +61,10 @@ body:after { #bookshelf > div { width: 100%; break-inside: avoid; - margin: 10px auto; + margin-top: 0; + margin-bottom: 20px; + margin-left: auto; + margin-right: auto; } #bookshelf > div > a { @@ -79,7 +81,7 @@ button { } table { - margin: 1em; + margin: 0 1em 1em; z-index: 10; border: 3px solid black; background-color: #f1f1f1; @@ -100,7 +102,7 @@ td { background-color: #f1f1f1; } .tdimage { - padding: 0 + padding: 0; } .tdimage > img { width: 100%;