Code Duplication    Length = 20-24 lines in 2 locations

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

@@ 62-85 (lines=24) @@
59
        """
60
        return self.context
61
62
    def getSRTemplates(self):
63
        """
64
        Returns a DisplayList with the available templates found in
65
        browser/samplinground/templates/
66
        """
67
        this_dir = os.path.dirname(os.path.abspath(__file__))
68
        templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR)
69
        tempath = '%s/%s' % (templates_dir, '*.pt')
70
        templates = [t.split('/')[-1] for t in glob.glob(tempath)]
71
        out = []
72
        for template in templates:
73
            out.append({'id': template, 'title': template[:-3]})
74
        for templates_resource in iterDirectoriesOfType(self._TEMPLATES_ADDON_DIR):
75
            prefix = templates_resource.__name__
76
            templates = [
77
                tpl for tpl in templates_resource.listDirectory()
78
                if tpl.endswith('.pt')
79
                ]
80
            for template in templates:
81
                out.append({
82
                    'id': '{0}:{1}'.format(prefix, template),
83
                    'title': '{0} ({1})'.format(template[:-3], prefix),
84
                })
85
        return out
86
87
    def getFormTemplate(self):
88
        """Returns the current samplinground rendered with the template

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

@@ 96-115 (lines=20) @@
93
                return analysis
94
        return None
95
96
    def getWSTemplates(self):
97
        """ Returns a DisplayList with the available templates found in
98
            templates/worksheets
99
        """
100
        this_dir = os.path.dirname(os.path.abspath(__file__))
101
        templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR)
102
        tempath = '%s/%s' % (templates_dir, '*.pt')
103
        templates = [t.split('/')[-1] for t in glob.glob(tempath)]
104
        out = []
105
        for template in templates:
106
            out.append({'id': template, 'title': template[:-3]})
107
        for templates_resource in iterDirectoriesOfType(self._TEMPLATES_ADDON_DIR):
108
            prefix = templates_resource.__name__
109
            templates = [tpl for tpl in templates_resource.listDirectory() if tpl.endswith('.pt')]
110
            for template in templates:
111
                out.append({
112
                    'id': '{0}:{1}'.format(prefix, template),
113
                    'title': '{0} ({1})'.format(template[:-3], prefix),
114
                })
115
        return out
116
117
    def renderWSTemplate(self):
118
        """ Returns the current worksheet rendered with the template