-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.py
25 lines (20 loc) · 981 Bytes
/
utility.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
# ############################################################################
# Repertory converter / parser / importer for OOREP (https://www.oorep.com/)
# Copyright (c) 2021 Andreas Bauer <[email protected]>
# License: GPL v3.0 (or higher)
import parser
import psycopg2
# Find those remedies in the parsed repertory that do not appear or have different names
# in the repertories stored already in OOREP's database
def printUniqueRemedies(rubrics: list[parser.Rubric], cursor: psycopg2._psycopg.cursor):
# Extract all local remedies from 'rubrics'
allRemedies = set()
for rubric in rubrics:
for remedy in rubric.remedies:
allRemedies.add(remedy.abbrev)
cursor.execute("select nameabbrev from remedy;")
dbRemedies = list(map(lambda x: x[0], cursor.fetchall()))
# Find and print those local remedies, which are not in the DB
for remedy in sorted(allRemedies):
if not remedy in sorted(dbRemedies):
print(remedy)