Code Duplication    Length = 16-24 lines in 2 locations

crabpy/gateway/capakey.py 2 locations

@@ 1139-1162 (lines=24) @@
1136
        return "Sectie('%s', %s)" % (self.id, repr(self.afdeling))
1137
1138
1139
def check_lazy_load_perceel(f):
1140
    '''
1141
    Decorator function to lazy load a :class:`Perceel`.
1142
    '''
1143
    def wrapper(self):
1144
        perceel = self
1145
        if (getattr(perceel, '_%s' % f.__name__, None) is None):
1146
            log.debug(
1147
                'Lazy loading Perceel %s in Sectie %s in Afdeling %d',
1148
                perceel.id,
1149
                perceel.sectie.id,
1150
                perceel.sectie.afdeling.id
1151
            )
1152
            perceel.check_gateway()
1153
            p = perceel.gateway.get_perceel_by_id_and_sectie(
1154
                perceel.id,
1155
                perceel.sectie
1156
            )
1157
            perceel._centroid = p._centroid
1158
            perceel._bounding_box = p._bounding_box
1159
            perceel._capatype = p._capatype
1160
            perceel._cashkey = p._cashkey
1161
        return f(self)
1162
    return wrapper
1163
1164
1165
class Perceel(GatewayObject):
@@ 980-995 (lines=16) @@
977
        return "Gemeente(%s, '%s')" % (self.id, self.naam)
978
979
980
def check_lazy_load_afdeling(f):
981
    '''
982
    Decorator function to lazy load a :class:`Afdeling`.
983
    '''
984
    def wrapper(self):
985
        afdeling = self
986
        if (getattr(afdeling, '_%s' % f.__name__, None) is None):
987
            log.debug('Lazy loading Afdeling %d', afdeling.id)
988
            afdeling.check_gateway()
989
            a = afdeling.gateway.get_kadastrale_afdeling_by_id(afdeling.id)
990
            afdeling._naam = a._naam
991
            afdeling._gemeente = a._gemeente
992
            afdeling._centroid = a._centroid
993
            afdeling._bounding_box = a._bounding_box
994
        return f(self)
995
    return wrapper
996
997
998
class Afdeling(GatewayObject):