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

@@ 2052-2073 (lines=22) @@
2049
        """
2050
        return self.getContainer() and [self.getContainer] or []
2051
2052
    def isAnalysisServiceHidden(self, uid):
2053
        """Checks if the analysis service that match with the uid provided must
2054
        be hidden in results. If no hidden assignment has been set for the
2055
        analysis in this request, returns the visibility set to the analysis
2056
        itself.
2057
2058
        Raise a TypeError if the uid is empty or None
2059
2060
        Raise a ValueError if there is no hidden assignment in this request or
2061
        no analysis service found for this uid.
2062
        """
2063
        if not uid:
2064
            raise TypeError('None type or empty uid')
2065
        sets = self.getAnalysisServiceSettings(uid)
2066
        if 'hidden' not in sets:
2067
            uc = getToolByName(self, 'uid_catalog')
2068
            serv = uc(UID=uid)
2069
            if serv and len(serv) == 1:
2070
                return serv[0].getObject().getRawHidden()
2071
            else:
2072
                raise ValueError('{} is not valid'.format(uid))
2073
        return sets.get('hidden', False)
2074
2075
    def getRejecter(self):
2076
        """If the Analysis Request has been rejected, returns the user who did the