-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTypes.py
More file actions
70 lines (51 loc) · 1.13 KB
/
Copy pathDataTypes.py
File metadata and controls
70 lines (51 loc) · 1.13 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Data Types
By Nicholas Robinson
This file holds classes of each data type that can be held in the ID Dictionary Class.
"""
"""
ID Object
By Nicholas Robinson
"""
class IDObject(object):
def __init__(self,id):
self.id = id
"""
User
By Nicholas Robinson
"""
class User(IDObject):
def __init__(self,id):
IDObject.__init__(self,id)
self.docsRead = {}
self.docTotalTime = 0
def readDoc(self, doc, time=0):
if not doc in self.docsRead:
self.docsRead[doc] = time
else:
self.docsRead[doc] += time
self.docTotalTime += time
def getDocs(self):
return [self.docsRead[doc] for doc in self.docsRead]
def getDocTimes(self):
return self.docsRead
"""
Document
By Nicholas Robinson
"""
class Document(IDObject):
def __init__(self,id):
IDObject.__init__(self,id)
self.usersRead = []
self.countriesRead = []
def userRead(self,user):
if not (user in self.usersRead):
self.usersRead.append(user)
def countryRead(self, country):
self.countriesRead.append(country)
def getReaders(self):
return self.usersRead
def getCountries(self):
return self.countriesRead