@@ -116,9 +116,23 @@ class EventStats(object):
116
116
117
117
def __init__ (self , platform , event , count ):
118
118
"""Create new instance of EventStats(platform, event, count)"""
119
- self .platform = platform
120
- self .event = event
121
- self .count = count
119
+ if isinstance (platform , six .string_types ) and platform in self ._platforms .keys ():
120
+ raise ValueError (('Raw string "{}" detected. Use a dynamic_links.PLATFORM_* constant' +
10000
div>
121
+ ' or the make_event_stat() method.' ).format (platform ))
122
+ if not isinstance (platform , six .string_types ) or platform not in self ._platforms .values ():
123
+ raise ValueError ('platform {}, not recognized' .format (platform ))
124
+ self ._platform = platform
125
+
126
+ if isinstance (event , six .string_types ) and event in self ._event_types .keys ():
127
+ raise ValueError (('Raw string {} detected. Use one of the dynamic_links.EVENT_TYPES_' +
128
+ ' constants, or the make_event_stat() method.' ).format (event ))
129
+ if not isinstance (event , six .string_types ) or event not in self ._event_types .values ():
130
+ raise ValueError ('event_type {}, not recognized' .format (event ))
131
+ self ._event = event
132
+
133
+ if not isinstance (count , int ) or isinstance (count , bool ) or count < 0 :
134
+ raise ValueError ('Count: {} must be a non negative int' .format (count ))
135
+ self ._count = count
122
136
123
137
def __repr__ (self ):
124
138
return "EventStats(platform: '{}', event: '{}', count: '{}')" .format (
@@ -136,38 +150,14 @@ def make_event_stat(cls, platform, event, count):
136
150
def platform (self ):
137
151
return self ._platform
138
152
139
- @platform .setter
140
- def platform (self , platform ):
141
- if isinstance (platform , six .string_types ) and platform in self ._platforms .keys ():
142
- raise ValueError (('Raw string {} detected. Use one of the dynamic_links.PLATFORM_...' +
143
- ' constants, or the make_event_stat() method.' ).format (platform ))
144
- if not isinstance (platform , six .string_types ) or platform not in self ._platforms .values ():
145
- raise ValueError ('platform {}, not recognized' .format (platform ))
146
- self ._platform = platform
147
-
148
153
@property
149
154
def event (self ):
150
155
return self ._event
151
156
152
- @event .setter
153
- def event (self , event ):
154
- if isinstance (event , six .string_types ) and event in self ._event_types .keys ():
155
- raise ValueError (('Raw string {} detected. Use one of the dynamic_links.EVENT_TYPES_' +
156
- ' constants, or the make_event_stat() method.' ).format (event ))
157
- if not isinstance (event , six .string_types ) or event not in self ._event_types .values ():
158
- raise ValueError ('event_type {}, not recognized' .format (event ))
159
- self ._event = event
160
-
161
157
@property
162
158
def count (self ):
163
159
return self ._count
164
160
165
- @count .setter
166
- def count (self , count ):
167
- if not isinstance (count , int ) or isinstance (count , bool ) or count < 0 :
168
- raise ValueError ('Count: {} must be a non negative int' .format (count ))
169
- self ._count = count
170
-
171
161
172
162
class StatOptions (object ):
173
163
def __init__ (self , duration_days ):
0 commit comments