-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposting.py
More file actions
26 lines (20 loc) · 811 Bytes
/
posting.py
File metadata and controls
26 lines (20 loc) · 811 Bytes
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
import traceback
class Posting:
def __init__(self, postingDict, num_posting_file):
self.postingDict = postingDict
self.path = 'posting{}.txt'.format(num_posting_file)
self.num_posting_file = num_posting_file
self.merge_file = []
self.merge_counter = 0
def get_posting_path(self):
return self.path
def create_posting_file(self):
try:
with open(self.path, 'a', encoding="cp437",errors='ignore') as f:
for key, value in sorted(self.postingDict.items()):
f.write("{} : {} \n".format(str(key), str(value)))
except:
print('problem with the following key sammm {}'.format(key))
print(traceback.print_exc())
def sort_by_id(self, value):
return value[0]