Code Duplication    Length = 12-13 lines in 2 locations

myems-api/reports/offlinemeterenergy.py 1 location

@@ 108-119 (lines=12) @@
105
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
106
                                   description='API.INVALID_BASE_PERIOD_END_DATETIME')
107
108
        if reporting_period_start_datetime is None:
109
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
110
                                   description="API.INVALID_REPORTING_PERIOD_START_DATETIME")
111
        else:
112
            reporting_period_start_datetime = str.strip(reporting_period_start_datetime)
113
            try:
114
                reporting_start_datetime_utc = datetime.strptime(reporting_period_start_datetime, '%Y-%m-%dT%H:%M:%S')
115
            except ValueError:
116
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
117
                                       description="API.INVALID_REPORTING_PERIOD_START_DATETIME")
118
            reporting_start_datetime_utc = reporting_start_datetime_utc.replace(tzinfo=timezone.utc) - \
119
                timedelta(minutes=timezone_offset)
120
121
        if reporting_period_end_datetime is None:
122
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',

myems-api/reports/offlinemeterdaily.py 1 location

@@ 69-81 (lines=13) @@
66
        if config.utc_offset[0] == '-':
67
            timezone_offset = -timezone_offset
68
69
        if reporting_period_start_datetime_local is None:
70
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
71
                                   description="API.INVALID_REPORTING_PERIOD_START_DATETIME")
72
        else:
73
            reporting_period_start_datetime_local = str.strip(reporting_period_start_datetime_local)
74
            try:
75
                reporting_start_datetime_utc = datetime.strptime(reporting_period_start_datetime_local,
76
                                                                 '%Y-%m-%dT%H:%M:%S')
77
            except ValueError:
78
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
79
                                       description="API.INVALID_REPORTING_PERIOD_START_DATETIME")
80
            reporting_start_datetime_utc = reporting_start_datetime_utc.replace(tzinfo=timezone.utc) - \
81
                timedelta(minutes=timezone_offset)
82
83
        if reporting_period_end_datetime_local is None:
84
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',