Code Duplication    Length = 19-19 lines in 2 locations

src/bika/lims/content/sampletype.py 1 location

@@ 239-257 (lines=19) @@
236
    def Title(self):
237
        return safe_unicode(self.getField('title').get(self)).encode('utf-8')
238
239
    def getJSMinimumVolume(self, **kw):
240
        """Try convert the MinimumVolume to 'ml' or 'g' so that JS has an
241
        easier time working with it.  If conversion fails, return raw value.
242
        """
243
        default = self.Schema()['MinimumVolume'].get(self)
244
        try:
245
            mgdefault = default.split(' ', 1)
246
            mgdefault = mg(float(mgdefault[0]), mgdefault[1])
247
        except Exception:
248
            mgdefault = mg(0, 'ml')
249
        try:
250
            return str(mgdefault.ounit('ml'))
251
        except Exception:
252
            pass
253
        try:
254
            return str(mgdefault.ounit('g'))
255
        except Exception:
256
            pass
257
        return str(default)
258
259
    def getDefaultLifetime(self):
260
        """ get the default retention period """

src/bika/lims/content/container.py 1 location

@@ 122-140 (lines=19) @@
119
        from bika.lims.idserver import renameAfterCreation
120
        renameAfterCreation(self)
121
122
    def getJSCapacity(self, **kw):
123
        """Try convert the Capacity to 'ml' or 'g' so that JS has an
124
        easier time working with it.  If conversion fails, return raw value.
125
        """
126
        default = self.Schema()['Capacity'].get(self)
127
        try:
128
            mgdefault = default.split(' ', 1)
129
            mgdefault = mg(float(mgdefault[0]), mgdefault[1])
130
        except Exception:
131
            mgdefault = mg(0, 'ml')
132
        try:
133
            return str(mgdefault.ounit('ml'))
134
        except Exception:
135
            pass
136
        try:
137
            return str(mgdefault.ounit('g'))
138
        except Exception:
139
            pass
140
        return str(default)
141
142
143
registerType(Container, PROJECTNAME)