From d669ee4dd2244880a7c8acc64a0c3df9532922dc Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Thu, 22 Oct 2020 01:34:08 +0200 Subject: wip: verify --- fuzzycat/verify.py | 41 +++++++++++++++++++++++++++++++++++++++++ setup.py | 1 + 2 files changed, 42 insertions(+) create mode 100644 fuzzycat/verify.py diff --git a/fuzzycat/verify.py b/fuzzycat/verify.py new file mode 100644 index 0000000..d4677b0 --- /dev/null +++ b/fuzzycat/verify.py @@ -0,0 +1,41 @@ +""" +Verification part of matching. + +We represent clusters as json lines. One example input line (prettified): + + { + "v": [ + "cjcpmod6pjaczbhrqfljdfl4m4", + "di5kdt5apfc6fiiqofjzkuiqey", + "fxhwvmc7dzc6bpuvo7ds4l5gx4", + "pda5cuevyrcmpgj3woxw7ktvz4", + "port5bx5nzb7tghqsjknnhs56y", + "x3a43yczavdkfhp3ekgt5hn6l4" + ], + "k": "1 Grundlagen", + "c": "t" + } + +Further steps: + +* fetch all releases, this might be via API, search index, some local key value +store, or some other cache +* apply various rules, return match status + +""" + +def fetch_release_entity(ident, api="https://api.fatcat.wiki/v0"): + """ + Fetches a single release entity. + """ + link = "https://api.fatcat.wiki/v0/release/{}".format(ident) + return requests.get(link).json() + +def ident_to_release_entities(ids): + """ + Turn a list of ids into release entities. + """ + return [fetch_release_entity(id) for id in ids] + + + diff --git a/setup.py b/setup.py index cdc6947..dd1834c 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ with open("README.md", "r") as fh: zip_safe=False, entry_points={"console_scripts": [ "fuzzycat-cluster=fuzzycat.cluster:main", + "fuzzycat-verify=fuzzycat.verify:main", ],}, install_requires=[ "elasticsearch>=7", -- cgit v1.2.3