Code Duplication    Length = 12-14 lines in 2 locations

bika/lims/browser/analysisrequest/add2.py 1 location

@@ 59-72 (lines=14) @@
56
        self.fieldvalues = self.generate_fieldvalues(self.obj_count)
57
        self.specifications = self.generate_specifications(self.obj_count)
58
        logger.info("*** Prepared data for {} ARs ***".format(self.obj_count))
59
        return self.template()
60
61
    def get_object_by_uid(self, uid):
62
        """Get the object by UID
63
        """
64
        logger.debug("get_object_by_uid::UID={}".format(uid))
65
        obj = api.get_object_by_uid(uid, None)
66
        if obj is None:
67
            logger.warn("!! No object found for UID #{} !!")
68
        return obj
69
70
    def is_ar_specs_allowed(self):
71
        """Checks if AR Specs are allowed
72
        """
73
        bika_setup = api.get_bika_setup()
74
        return bika_setup.getEnableARSpecs()
75

bika/lims/jsonapi/calculate_partitions.py 1 location

@@ 14-25 (lines=12) @@
11
from zExceptions import BadRequest
12
from zope import interface
13
import magnitude
14
15
16
def mg(value):
17
    tokens = value.split(" ") if value else [0, '']
18
    val = float(tokens[0]) if isinstance(tokens[0], (int, long)) else 0
19
    unit = tokens[1] if len(tokens) > 1 else ''
20
    # Magnitude doesn't support mL units.
21
    # Since mL is commonly used instead of ml to avoid confusion with the
22
    # number one, add "L" (for liter) as a 'recognizable' unit.
23
    # L unit as liter is also recommended by the NIST Guide
24
    # http://physics.nist.gov/Pubs/SP811/sec05.html#table6
25
    # Further info: https://jira.bikalabs.com/browse/LIMS-1441
26
    unit = unit[:-1]+'l' if unit.endswith('L') else unit
27
    return magnitude.mg(val, unit)
28