-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatastruct.py
More file actions
68 lines (45 loc) · 1.62 KB
/
Copy pathdatastruct.py
File metadata and controls
68 lines (45 loc) · 1.62 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
# class UserData:
# """class to save user name and his registered channels. """
# def __init__(self, DisplayName):
# self.DisplayName = DisplayName
# self.ChannelList = []
# def RegisterChannel(self, ChhanelName):
# if ( ( None == ChhanelName ) or (not(ChhanelName and ChhanelName.strip())) ) :
# return "Channel name is not valid"
# if ( ChhanelName in self.ChannelList ):
# return "Already registered with this channel"
# self.ChannelList.append (ChhanelName)
# return True
class User:
def __init__(self, username):
self.username = username
@staticmethod
def is_authenticated():
return True
@staticmethod
def is_active():
return True
@staticmethod
def is_anonymous():
return False
def get_id(self):
return self.username
class PostData:
"""class to store individual post data. """
LastPostID = 0
def __init__(self, UserName , PostDate , PostString):
self.UserName = UserName
self.PostDate = PostDate
self.PostString = PostString
self.PostID = PostData.LastPostID + 1
PostData.LastPostID += 1
class Channeldata:
"""class to store individual channel data. """
LastChannelID = 0
def __init__(self, ChannelName , ChannelGenre):
self.ChannelName = ChannelName
self.ChannelGenre = ChannelGenre
self.ChannelID = Channeldata.LastChannelID + 1
Channeldata.LastChannelID += 1
def get_user(username):
return User(username) if username and username.strip else None