Code Duplication    Length = 13-13 lines in 3 locations

src/ocrd_models/ocrd_page_generateds.py 3 locations

@@ 495-507 (lines=13) @@
492
    @classmethod
493
    def gds_parse_time(cls, input_data):
494
        tz = None
495
        if input_data[-1] == 'Z':
496
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
497
            input_data = input_data[:-1]
498
        else:
499
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
500
            if results is not None:
501
                tzoff_parts = results.group(2).split(':')
502
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
503
                if results.group(1) == '-':
504
                    tzoff *= -1
505
                tz = GeneratedsSuper._FixedOffsetTZ(
506
                    tzoff, results.group(0))
507
                input_data = input_data[:-6]
508
        if len(input_data.split('.')) > 1:
509
            dt = datetime_.datetime.strptime(input_data, '%H:%M:%S.%f')
510
        else:
@@ 428-440 (lines=13) @@
425
    @classmethod
426
    def gds_parse_date(cls, input_data):
427
        tz = None
428
        if input_data[-1] == 'Z':
429
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
430
            input_data = input_data[:-1]
431
        else:
432
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
433
            if results is not None:
434
                tzoff_parts = results.group(2).split(':')
435
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
436
                if results.group(1) == '-':
437
                    tzoff *= -1
438
                tz = GeneratedsSuper._FixedOffsetTZ(
439
                    tzoff, results.group(0))
440
                input_data = input_data[:-6]
441
        dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')
442
        dt = dt.replace(tzinfo=tz)
443
        return dt.date()
@@ 372-384 (lines=13) @@
369
    @classmethod
370
    def gds_parse_datetime(cls, input_data):
371
        tz = None
372
        if input_data[-1] == 'Z':
373
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
374
            input_data = input_data[:-1]
375
        else:
376
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
377
            if results is not None:
378
                tzoff_parts = results.group(2).split(':')
379
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
380
                if results.group(1) == '-':
381
                    tzoff *= -1
382
                tz = GeneratedsSuper._FixedOffsetTZ(
383
                    tzoff, results.group(0))
384
                input_data = input_data[:-6]
385
        time_parts = input_data.split('.')
386
        if len(time_parts) > 1:
387
            micro_seconds = int(float('0.' + time_parts[1]) * 1000000)