@@ -116,9 +116,23 @@ class EventStats(object):
116116
117117 def __init__ (self , platform , event , count ):
118118 """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' +
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
122136
123137 def __repr__ (self ):
124138 return "EventStats(platform: '{}', event: '{}', count: '{}')" .format (
@@ -136,38 +150,14 @@ def make_event_stat(cls, platform, event, count):
136150 def platform (self ):
137151 return self ._platform
138152
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-
148153 @property
149154 def event (self ):
150155 return self ._event
151156
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-
161157 @property
162158 def count (self ):
163159 return self ._count
164160
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-
171161
172162class StatOptions (object ):
173163 def __init__ (self , duration_days ):
0 commit comments