Code Duplication    Length = 21-22 lines in 3 locations

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

@@ 174-194 (lines=21) @@
171
                if s.get('uid','') == uid]
172
        return sets[0] if sets else {'uid': uid}
173
174
    def isAnalysisServiceHidden(self, uid):
175
        """ Checks if the analysis service that match with the uid
176
            provided must be hidden in results.
177
            If no hidden assignment has been set for the analysis in
178
            this profile, returns the visibility set to the analysis
179
            itself.
180
            Raise a TypeError if the uid is empty or None
181
            Raise a ValueError if there is no hidden assignment in this
182
                profile or no analysis service found for this uid.
183
        """
184
        if not uid:
185
            raise TypeError('None type or empty uid')
186
        sets = self.getAnalysisServiceSettings(uid)
187
        if 'hidden' not in sets:
188
            uc = getToolByName(self, 'uid_catalog')
189
            serv = uc(UID=uid)
190
            if serv and len(serv) == 1:
191
                return serv[0].getObject().getRawHidden()
192
            else:
193
                raise ValueError('%s is not valid' % uid)
194
        return sets.get('hidden', False)
195
196
    def getVATAmount(self):
197
        """ Compute AnalysisProfileVATAmount

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

@@ 326-346 (lines=21) @@
323
        sets = [s for s in settings if s.get("uid", "") == uid]
324
        return sets[0] if sets else {"uid": uid}
325
326
    def isAnalysisServiceHidden(self, uid):
327
        """ Checks if the analysis service that match with the uid
328
            provided must be hidden in results.
329
            If no hidden assignment has been set for the analysis in
330
            this template, returns the visibility set to the analysis
331
            itself.
332
            Raise a TypeError if the uid is empty or None
333
            Raise a ValueError if there is no hidden assignment in this
334
                template or no analysis service found for this uid.
335
        """
336
        if not uid:
337
            raise TypeError("None type or empty uid")
338
        sets = self.getAnalysisServiceSettings(uid)
339
        if "hidden" not in sets:
340
            uc = getToolByName(self, "uid_catalog")
341
            serv = uc(UID=uid)
342
            if serv and len(serv) == 1:
343
                return serv[0].getObject().getRawHidden()
344
            else:
345
                raise ValueError("%s is not valid" % uid)
346
        return sets.get("hidden", False)
347
348
    def remove_service(self, service):
349
        """Removes the service passed in from the services offered by the

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

@@ 2034-2055 (lines=22) @@
2031
        """
2032
        return self.getContainer() and [self.getContainer] or []
2033
2034
    def isAnalysisServiceHidden(self, uid):
2035
        """Checks if the analysis service that match with the uid provided must
2036
        be hidden in results. If no hidden assignment has been set for the
2037
        analysis in this request, returns the visibility set to the analysis
2038
        itself.
2039
2040
        Raise a TypeError if the uid is empty or None
2041
2042
        Raise a ValueError if there is no hidden assignment in this request or
2043
        no analysis service found for this uid.
2044
        """
2045
        if not uid:
2046
            raise TypeError('None type or empty uid')
2047
        sets = self.getAnalysisServiceSettings(uid)
2048
        if 'hidden' not in sets:
2049
            uc = getToolByName(self, 'uid_catalog')
2050
            serv = uc(UID=uid)
2051
            if serv and len(serv) == 1:
2052
                return serv[0].getObject().getRawHidden()
2053
            else:
2054
                raise ValueError('{} is not valid'.format(uid))
2055
        return sets.get('hidden', False)
2056
2057
    def getRejecter(self):
2058
        """If the Analysis Request has been rejected, returns the user who did the