-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorderAbbreviation.py
46 lines (33 loc) · 2.08 KB
/
orderAbbreviation.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from functools import wraps
def orderAbbreviation(wrapped_function):
@wraps(wrapped_function)
def _wrapper(*args, **kwargs):
results = wrapped_function(*args, **kwargs)
results = [r for r in results if not ("SJ" in r["name"] and not "SJP" in r["name"])]
results = [r for r in results if not(("SchP" in r["name"] or "SP" in r["name"] or "Sch. P" in r["name"] ) and not "OSPPE" in r["name"])]
deleteFromDiocese = ["SDB"]
for d in deleteFromDiocese:
results = [r for r in results if not d in r["name"]]
new_results = []
orderAbbreviations = ["SJP", "OFM Conv.", "OSB", "OP", "SDS", "SVD", "FSCB", "OSPPE", "FSO", "SDB", "OCD", "OH", "TORG", "SMC", "OFM", "MI", "CM"]
for r in results:
if "O.Praem." in r["name"] or "O.Praem" in r["name"] or "OPraem" in r["name"]:
r["name"] = r["name"].replace("O.Praem.", "").replace("O.Praem", "").replace("OPraem", "")
r["orderAbbreviation"] = "OPraem"
if "O.Cist." in r["name"] or "O. Cist" in r["name"] or "O.Cist" in r["name"]:
r["name"] = r["name"].replace("O.Cist.", "").replace("O. Cist", "").replace("O.Cist", "")
r["orderAbbreviation"] = "OCist"
if "OFMCap" in r["name"] or "OFM Cap" in r["name"] or "OFM Cap." in r["name"]:
r["name"] = r["name"].replace("OFMCap", "").replace("OFM Cap.", "").replace("OFM Cap", "")
r["orderAbbreviation"] = "OFMCap"
if "SChr." in r["name"]:
r["name"] = r["name"].replace("SChr.", "")
r["orderAbbreviation"] = "SChr"
for oa in orderAbbreviations:
if oa in r["name"]:
r["name"] = r["name"].replace(oa, "")
r["orderAbbreviation"] = oa
r["name"] = r["name"].strip()
new_results.append(r)
return new_results
return _wrapper