Code Duplication    Length = 21-22 lines in 3 locations

bika/lims/browser/samplinground/printform.py 1 location

@@ 109-130 (lines=22) @@
106
            self._current_sr_index += 1
107
        return reptemplate
108
109
    def getCSS(self):
110
        """ Returns the css style to be used for the current template.
111
            If the selected template is 'default.pt', this method will
112
            return the content from 'default.css'. If no css file found
113
            for the current template, returns empty string
114
        """
115
        template = self.request.get('template', self._DEFAULT_TEMPLATE)
116
        content = ''
117
        if template.find(':') >= 0:
118
            prefix, template = template.split(':')
119
            resource = queryResourceDirectory(
120
                self._TEMPLATES_ADDON_DIR, prefix)
121
            css = '{0}.css'.format(template[:-3])
122
            if css in resource.listDirectory():
123
                content = resource.readFile(css)
124
        else:
125
            this_dir = os.path.dirname(os.path.abspath(__file__))
126
            templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR)
127
            path = '%s/%s.css' % (templates_dir, template[:-3])
128
            with open(path, 'r') as content_file:
129
                content = content_file.read()
130
        return content
131
132
    def getAnalysisRequestTemplatesInfo(self):
133
        """

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

@@ 234-254 (lines=21) @@
231
        self._nextAnalysisRequestGroup()
232
        return reptemplate
233
234
    def getReportStyle(self):
235
        """Returns the css style to be used for the current template.
236
        If the selected template is 'default.pt', this method will
237
        return the content from 'default.css'. If no css file found
238
        for the current template, returns empty string
239
        """
240
        template = self.request.form.get('template', self._DEFAULT_TEMPLATE)
241
        content = ''
242
        if template.find(':') >= 0:
243
            prefix, template = template.split(':')
244
            resource = queryResourceDirectory('reports', prefix)
245
            css = '{0}.css'.format(template[:-3])
246
            if css in resource.listDirectory():
247
                content = resource.readFile(css)
248
        else:
249
            this_dir = os.path.dirname(os.path.abspath(__file__))
250
            templates_dir = os.path.join(this_dir, 'templates/reports/')
251
            path = '%s/%s.css' % (templates_dir, template[:-3])
252
            with open(path, 'r') as content_file:
253
                content = content_file.read()
254
        return content
255
256
    def isSingleARTemplate(self):
257
        seltemplate = self.request.form.get('template', self._DEFAULT_TEMPLATE)

bika/lims/browser/worksheet/views/printview.py 1 location

@@ 139-159 (lines=21) @@
136
            self._current_ws_index += 1
137
        return reptemplate
138
139
    def getCSS(self):
140
        """ Returns the css style to be used for the current template.
141
            If the selected template is 'default.pt', this method will
142
            return the content from 'default.css'. If no css file found
143
            for the current template, returns empty string
144
        """
145
        template = self.request.get('template', self._DEFAULT_TEMPLATE)
146
        content = ''
147
        if template.find(':') >= 0:
148
            prefix, template = template.split(':')
149
            resource = queryResourceDirectory(self._TEMPLATES_ADDON_DIR, prefix)
150
            css = '{0}.css'.format(template[:-3])
151
            if css in resource.listDirectory():
152
                content = resource.readFile(css)
153
        else:
154
            this_dir = os.path.dirname(os.path.abspath(__file__))
155
            templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR)
156
            path = '%s/%s.css' % (templates_dir, template[:-3])
157
            with open(path, 'r') as content_file:
158
                content = content_file.read()
159
        return content
160
161
    def getNumColumns(self):
162
        """ Returns the number of columns to display