Code Duplication    Length = 24-24 lines in 2 locations

client/osci/dialog/NewTaskDlg.py 1 location

@@ 240-263 (lines=24) @@
237
        # quantity
238
        self.win.vQuantity.text = str(self.quantity)
239
240
    def showSlots(self):
241
        # techs
242
        items = []
243
        techs = {}
244
        if self.showStructures:
245
            player = client.getPlayer()
246
            target = client.get(self.targetID, noUpdate=1)
247
            if hasattr(target, 'slots') and target.owner == player.oid:
248
                if len(target.slots) < target.plSlots:
249
                    item = ui.Item(_("Free slot"), techID=0)
250
                    items.append(item)
251
                for struct in target.slots:
252
                    if not struct[Const.STRUCT_IDX_TECHID] in techs:
253
                        techs[struct[Const.STRUCT_IDX_TECHID]] = 1
254
                    else:
255
                        techs[struct[Const.STRUCT_IDX_TECHID]] += 1
256
                for tech in techs.keys():
257
                    techInfo = client.getTechInfo(tech)
258
                    item = ui.Item("%s (%d)" % (techInfo.name, techs[tech]), techID=tech)
259
                    items.append(item)
260
261
        self.win.vTSlots.items = items
262
        self.win.vTSlots.itemsChanged()
263
        self.structToDemolish = Const.OID_NONE
264
265
    def onSelectPlanet(self, widget, action, data):
266
        self.quantity = int(self.win.vQuantity.text)

client/osci/dialog/NewGlobalTaskDlg.py 1 location

@@ 154-177 (lines=24) @@
151
        # quantity
152
        self.win.vQuantity.text = str(self.quantity)
153
154
    def showSlots(self):
155
        # techs
156
        items = []
157
        techs = {}
158
        if self.showStructures:
159
            player = client.getPlayer()
160
            target = client.get(self.targetID, noUpdate=1)
161
            if hasattr(target, 'slots') and target.owner == player.oid:
162
                if len(target.slots) < target.plSlots:
163
                    item = ui.Item(_("Free slot"), techID=0)
164
                    items.append(item)
165
                for struct in target.slots:
166
                    if not struct[Const.STRUCT_IDX_TECHID] in techs:
167
                        techs[struct[Const.STRUCT_IDX_TECHID]] = 1
168
                    else:
169
                        techs[struct[Const.STRUCT_IDX_TECHID]] += 1
170
                for tech in techs.keys():
171
                    techInfo = client.getTechInfo(tech)
172
                    item = ui.Item("%s (%d)" % (techInfo.name, techs[tech]), techID=tech)
173
                    items.append(item)
174
175
        self.win.vTSlots.items = items
176
        self.win.vTSlots.itemsChanged()
177
        self.structToDemolish = Const.OID_NONE
178
179
180
    def onSelectTech(self, widget, action, data):