Code Duplication    Length = 12-12 lines in 3 locations

myems-api/core/wechatmessage.py 1 location

@@ 182-193 (lines=12) @@
179
        if config.utc_offset[0] == '-':
180
            timezone_offset = -timezone_offset
181
182
        if created_datetime_local is None:
183
            raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
184
                                   description="API.INVALID_CREATED_DATETIME")
185
        else:
186
            created_datetime_local = str.strip(created_datetime_local)
187
            try:
188
                created_datetime_utc = datetime.strptime(created_datetime_local,
189
                                                         '%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
190
                                     timedelta(minutes=timezone_offset)
191
            except ValueError:
192
                raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
193
                                       description="API.INVALID_CREATED_DATETIME")
194
195
        if scheduled_datetime_local is None:
196
            raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',

myems-api/core/emailmessage.py 1 location

@@ 175-186 (lines=12) @@
172
        if config.utc_offset[0] == '-':
173
            timezone_offset = -timezone_offset
174
175
        if created_datetime_local is None:
176
            raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
177
                                   description="API.INVALID_CREATED_DATETIME")
178
        else:
179
            created_datetime_local = str.strip(created_datetime_local)
180
            try:
181
                created_datetime_utc = datetime.strptime(created_datetime_local,
182
                                                         '%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
183
                                     timedelta(minutes=timezone_offset)
184
            except ValueError:
185
                raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
186
                                       description="API.INVALID_CREATED_DATETIME")
187
188
        if scheduled_datetime_local is None:
189
            raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',

myems-api/core/textmessage.py 1 location

@@ 158-169 (lines=12) @@
155
        if config.utc_offset[0] == '-':
156
            timezone_offset = -timezone_offset
157
158
        if created_datetime_local is None:
159
            raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
160
                                   description="API.INVALID_CREATED_DATETIME")
161
        else:
162
            created_datetime_local = str.strip(created_datetime_local)
163
            try:
164
                created_datetime_utc = datetime.strptime(created_datetime_local,
165
                                                         '%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
166
                                     timedelta(minutes=timezone_offset)
167
            except ValueError:
168
                raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
169
                                       description="API.INVALID_CREATED_DATETIME")
170
171
        if scheduled_datetime_local is None:
172
            raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',