Code Duplication    Length = 12-13 lines in 2 locations

omaha_server/omaha/limitation.py 2 locations

@@ 91-103 (lines=13) @@
88
    result['size'] = qs.get_size()
89
    elements = list(qs.values_list('id', 'created'))
90
    result['elements'] = map(lambda x: dict(id=x[0], element_created=x[1].strftime("%d. %B %Y %I:%M%p")), elements)
91
    qs.delete()
92
    return result
93
94
95
@bulk_delete.register(SparkleVersion)
96
def _(cls, qs):
97
    if settings.DEFAULT_FILE_STORAGE == 'storages.backends.s3boto.S3BotoStorage':
98
        qs = s3_bulk_delete(qs, file_fields=['file'], s3_fields=['sparkle'])
99
100
    result = dict()
101
    result['count'] = qs.count()
102
    result['size'] = qs.get_size()
103
    result['elements'] = list(qs.values_list('id', 'created'))
104
    elements = list(qs.values_list('id', 'created'))
105
    result['elements'] = map(lambda x: dict(id=x[0], element_created=x[1].strftime("%d. %B %Y %I:%M%p")), elements)
106
    qs.delete()
@@ 63-74 (lines=12) @@
60
    result['size'] = qs.get_size()
61
    elements = list(qs.values_list('id', 'created'))
62
    result['elements'] = map(lambda x: dict(id=x[0], element_created=x[1].strftime("%d. %B %Y %I:%M%p")), elements)
63
    qs.delete()
64
    return result
65
66
67
@bulk_delete.register(Symbols)
68
def _(cls, qs):
69
    if settings.DEFAULT_FILE_STORAGE == 'storages.backends.s3boto.S3BotoStorage':
70
        qs = s3_bulk_delete(qs, file_fields=['file'], s3_fields=['symbols'])
71
72
    result = dict()
73
    result['count'] = qs.count()
74
    result['size'] = qs.get_size()
75
    elements = list(qs.values_list('id', 'created'))
76
    result['elements'] = map(lambda x: dict(id=x[0], element_created=x[1].strftime("%d. %B %Y %I:%M%p")), elements)
77
    qs.delete()