Code Duplication    Length = 16-18 lines in 2 locations

isomer/ui/objectmanager/crud.py 2 locations

@@ 308-325 (lines=18) @@
305
                try:
306
                    if not self._check_permissions(schema, user, "list", item):
307
                        continue
308
                    if fields in ("*", ["*"]):
309
                        item_fields = item.serializablefields()
310
                        for field in hidden:
311
                            item_fields.pop(field, None)
312
                        object_list.append(item_fields)
313
                    else:
314
                        list_item = {"uuid": item.uuid}
315
316
                        if "name" in item._fields:
317
                            list_item["name"] = item._fields["name"]
318
319
                        for field in fields:
320
                            if field in item._fields and field not in hidden:
321
                                list_item[field] = item._fields[field]
322
                            else:
323
                                list_item[field] = None
324
325
                        object_list.append(list_item)
326
                except Exception as e:
327
                    self.log(
328
                        "Faulty object or field: ",
@@ 236-251 (lines=16) @@
233
234
            try:
235
                list_item = {"uuid": item.uuid}
236
                if fields in ("*", ["*"]):
237
                    item_fields = item.serializablefields()
238
                    for field in hidden:
239
                        item_fields.pop(field, None)
240
                    object_list.append(item_fields)
241
                else:
242
                    if "name" in item._fields:
243
                        list_item["name"] = item.name
244
245
                    for field in fields:
246
                        if field in item._fields and field not in hidden:
247
                            list_item[field] = item._fields[field]
248
                        else:
249
                            list_item[field] = None
250
251
                    object_list.append(list_item)
252
253
                if do_subscribe:
254
                    self._add_subscription(item.uuid, event)