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

@@ 350-370 (lines=21) @@
347
        sets = [s for s in settings if s.get("uid", "") == uid]
348
        return sets[0] if sets else {"uid": uid}
349
350
    def isAnalysisServiceHidden(self, uid):
351
        """ Checks if the analysis service that match with the uid
352
            provided must be hidden in results.
353
            If no hidden assignment has been set for the analysis in
354
            this template, returns the visibility set to the analysis
355
            itself.
356
            Raise a TypeError if the uid is empty or None
357
            Raise a ValueError if there is no hidden assignment in this
358
                template or no analysis service found for this uid.
359
        """
360
        if not uid:
361
            raise TypeError("None type or empty uid")
362
        sets = self.getAnalysisServiceSettings(uid)
363
        if "hidden" not in sets:
364
            uc = getToolByName(self, "uid_catalog")
365
            serv = uc(UID=uid)
366
            if serv and len(serv) == 1:
367
                return serv[0].getObject().getRawHidden()
368
            else:
369
                raise ValueError("%s is not valid" % uid)
370
        return sets.get("hidden", False)
371
372
    def remove_service(self, service):
373
        """Removes the service passed in from the services offered by the

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

@@ 2168-2189 (lines=22) @@
2165
        """
2166
        return self.getContainer() and [self.getContainer] or []
2167
2168
    def isAnalysisServiceHidden(self, uid):
2169
        """Checks if the analysis service that match with the uid provided must
2170
        be hidden in results. If no hidden assignment has been set for the
2171
        analysis in this request, returns the visibility set to the analysis
2172
        itself.
2173
2174
        Raise a TypeError if the uid is empty or None
2175
2176
        Raise a ValueError if there is no hidden assignment in this request or
2177
        no analysis service found for this uid.
2178
        """
2179
        if not uid:
2180
            raise TypeError('None type or empty uid')
2181
        sets = self.getAnalysisServiceSettings(uid)
2182
        if 'hidden' not in sets:
2183
            uc = getToolByName(self, 'uid_catalog')
2184
            serv = uc(UID=uid)
2185
            if serv and len(serv) == 1:
2186
                return serv[0].getObject().getRawHidden()
2187
            else:
2188
                raise ValueError('{} is not valid'.format(uid))
2189
        return sets.get('hidden', False)
2190
2191
    def getRejecter(self):
2192
        """If the Analysis Request has been rejected, returns the user who did the