Code Duplication    Length = 20-22 lines in 2 locations

bika/lims/browser/widgets/analysisspecificationwidget.py 1 location

@@ 302-323 (lines=22) @@
299
                                                     check_floatable=False)})
300
        return values, {}
301
302
    def _get_spec_value(self, form, uid, key, check_floatable=True,
303
                        default=''):
304
        """Returns the value assigned to the passed in key for the analysis
305
        service uid from the passed in form.
306
307
        If check_floatable is true, will return the passed in default if the
308
        obtained value is not floatable
309
310
        :param form: form being submitted
311
        :param uid: uid of the Analysis Service the specification relates
312
        :param key: id of the specs param to get (e.g. 'min')
313
        :param check_floatable: check if the value is floatable
314
        :param default: fallback value that will be returned by default
315
        :type default: str, None
316
        """
317
        if not form or not uid:
318
            return default
319
        values = form.get(key, None)
320
        if not values or len(values) == 0:
321
            return default
322
        value = values[0].get(uid, default)
323
        if not check_floatable:
324
            return value
325
        return api.is_floatable(value) and value or default
326

bika/lims/browser/widgets/referenceresultswidget.py 1 location

@@ 226-245 (lines=20) @@
223
224
        return values, {}
225
226
    def _get_spec_value(self, form, uid, key, default=''):
227
        """Returns the value assigned to the passed in key for the analysis
228
        service uid from the passed in form.
229
230
        If check_floatable is true, will return the passed in default if the
231
        obtained value is not floatable
232
        :param form: form being submitted
233
        :param uid: uid of the Analysis Service the specification relates
234
        :param key: id of the specs param to get (e.g. 'min')
235
        :param check_floatable: check if the value is floatable
236
        :param default: fallback value that will be returned by default
237
        :type default: str, None
238
        """
239
        if not form or not uid:
240
            return default
241
        values = form.get(key, None)
242
        if not values or len(values) == 0:
243
            return default
244
        value = values[0].get(uid, default)
245
        return api.is_floatable(value) and value or default
246
247
    security.declarePublic("ReferenceResults")
248