~nmu-sscheel/gtg/rework-task-editor

« back to all changes in this revision

Viewing changes to GTG/plugins/export/templates.py

  • Committer: Bertrand Rousseau
  • Date: 2012-05-09 22:33:25 UTC
  • mfrom: (1178 trunk)
  • mto: This revision was merged to the branch mainline in revision 1179.
  • Revision ID: bertrand.rousseau@gmail.com-20120509223325-a53d8nwo0x9g93bc
Merge nimit branch and trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from GTG.tools.borg import Borg
23
23
 
24
24
 
25
 
 
26
25
class TemplateFactory(Borg):
27
26
    '''
28
27
    A Factory which provides an easy access to the templates. It caches
29
28
    templates for the sake of speed.
30
29
    '''
31
30
 
32
 
 
33
31
    TEMPLATE_PATHS = [\
34
32
            os.path.join(xdg_config_home,
35
33
                         "gtg/plugins/export/export_templates"),
94
92
                pass
95
93
 
96
94
    @classmethod
97
 
    def __find_template_file(cls, path,  prefix, suffix = ""):
98
 
        directory = os.path.dirname(path)
99
 
        path= os.path.join(os.path.dirname(path),
100
 
                            os.path.basename(path).replace(\
101
 
                                    "template_", prefix))
102
 
        path = "%s*" %path[: path.rindex(".") - 1]
 
95
    def __find_template_file(cls, path, prefix, suffix = ""):
 
96
        basename = os.path.basename(path).replace("template_", prefix)
 
97
        path = os.path.join(os.path.dirname(path), basename)
 
98
                            
 
99
        path = "%s*" % path[: path.rindex(".") - 1]
103
100
        try:
104
101
            possible_paths = glob.glob(path)
105
102
            return filter(lambda p: p.endswith(suffix), possible_paths)[0]