-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchEngine.py
More file actions
75 lines (66 loc) · 1.84 KB
/
SearchEngine.py
File metadata and controls
75 lines (66 loc) · 1.84 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#SearchEngine
from Media import Media
from Book import Book
from Periodical import Periodical
from Video import Video
from Film import Film
class SearchEngine(Media):
global CardCatalog
CardCatalog = list()
def __init__ (self):
inf = open('book.txt','r')
if inf.closed:
print("Error opening file.")
for i in inf.readlines():
mystring = i.strip().split('|')
CardCatalog.append(Book(*mystring))
inf.close()
inf = open('periodic.txt','r')
if inf.closed:
print("Error opening file.")
for i in inf.readlines():
mystring = i.strip().split('|')
CardCatalog.append(Periodical(*mystring))
inf.close()
inf = open('video.txt','r')
if inf.closed:
print("Error opening file.")
for i in inf.readlines():
mystring = i.strip().split('|')
CardCatalog.append(Video(*mystring))
inf.close()
inf = open('film.txt','r')
if inf.closed:
print("Error opening file.")
for i in inf.readlines():
mystring = i.strip().split('|')
CardCatalog.append(Film(*mystring))
inf.close()
def search_title(self, search):
result_list = list()
for i in CardCatalog:
found = i.compare_title(search)
if found:
result_list.append(i)
return result_list
def search_call_no(self, search):
result_list = list()
for i in CardCatalog:
found = i.compare_call_no(search)
if found:
result_list.append(i)
return result_list
def search_subject(self, search):
result_list = list()
for i in CardCatalog:
found = i.compare_subject(search)
if found:
result_list.append(i)
return result_list
def search_other(self, search):
result_list = list()
for i in CardCatalog:
found = i.compare_other(search)
if found:
result_list.append(i)
return result_list