This repository was archived by the owner on May 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHelpSearch.py
More file actions
executable file
·60 lines (52 loc) · 1.98 KB
/
HelpSearch.py
File metadata and controls
executable file
·60 lines (52 loc) · 1.98 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
"""Search for CDR Help ("Documentation") documents.
"""
from cdrcgi import AdvancedSearch
class DocumentationSearch(AdvancedSearch):
"""Customize search for this document type."""
DOCTYPE = "Documentation"
SUBTITLE = DOCTYPE
FILTER = "name:Documentation Help Screens Filter"
PATHS = {
"doctype": (
"/Documentation/Metadata/DocType",
),
"function": (
"/Documentation/Metadata/Function",
),
"keyword": (
"/Documentation/Metadata/Subject",
"/Documentation/Body/DocumentationTitle",
),
"infotype": (
"/Documentation/@InfoType",
),
}
PICKLIST_FIELDS = "doctype", "function", "infotype"
def __init__(self):
AdvancedSearch.__init__(self)
self.doctype = self.fields.getvalue("doctype")
self.infotype = self.fields.getvalue("infotype")
self.function = self.fields.getvalue("function")
self.keyword = self.fields.getvalue("keyword")
for name in self.PICKLIST_FIELDS:
values = self.values_for_paths(self.PATHS[name])
value = getattr(self, name)
if value and value not in values:
raise Exception("Tampering with form values")
setattr(self, f"{name}s", [""] + values)
dtype_opts = dict(label="Document Type", options=self.doctypes)
itype_opts = dict(label="Information Type", options=self.infotypes)
self.search_fields = (
# pylint: disable=no-member
self.select("doctype", **dtype_opts),
self.select("function", options=self.functions),
self.text_field("keyword"),
self.select("infotype", **itype_opts),
)
self.query_fields = []
for name, paths in self.PATHS.items():
field = self.QueryField(getattr(self, name), paths)
self.query_fields.append(field)
if __name__ == "__main__":
DocumentationSearch().run()