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

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