Mercurial > piecrust2
comparison piecrust/processing/base.py @ 55:45828c4167ad
Processors can match on other things than just the extension.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 25 Aug 2014 21:40:25 -0700 |
parents | 2f717f961996 |
children | 6827dcc9d3fb |
comparison
equal
deleted
inserted
replaced
54:a46354306738 | 55:45828c4167ad |
---|---|
34 pass | 34 pass |
35 | 35 |
36 def onPipelineEnd(self, pipeline): | 36 def onPipelineEnd(self, pipeline): |
37 pass | 37 pass |
38 | 38 |
39 def supportsExtension(self, ext): | 39 def matches(self, filename): |
40 return False | 40 return False |
41 | 41 |
42 def getDependencies(self, path): | 42 def getDependencies(self, path): |
43 return None | 43 return None |
44 | 44 |
54 | 54 |
55 def __init__(self): | 55 def __init__(self): |
56 super(CopyFileProcessor, self).__init__() | 56 super(CopyFileProcessor, self).__init__() |
57 self.priority = PRIORITY_LAST | 57 self.priority = PRIORITY_LAST |
58 | 58 |
59 def supportsExtension(self, ext): | 59 def matches(self, filename): |
60 return True | 60 return True |
61 | 61 |
62 def getOutputFilenames(self, filename): | 62 def getOutputFilenames(self, filename): |
63 return [filename] | 63 return [filename] |
64 | 64 |
72 class SimpleFileProcessor(Processor): | 72 class SimpleFileProcessor(Processor): |
73 def __init__(self, extensions=None): | 73 def __init__(self, extensions=None): |
74 super(SimpleFileProcessor, self).__init__() | 74 super(SimpleFileProcessor, self).__init__() |
75 self.extensions = extensions or {} | 75 self.extensions = extensions or {} |
76 | 76 |
77 def supportsExtension(self, ext): | 77 def matches(self, filename): |
78 return ext.lstrip('.') in self.extensions | 78 for ext in self.extensions: |
79 if filename.endswith('.' + ext): | |
80 return True | |
81 return False | |
79 | 82 |
80 def getOutputFilenames(self, filename): | 83 def getOutputFilenames(self, filename): |
81 basename, ext = os.path.splitext(filename) | 84 basename, ext = os.path.splitext(filename) |
82 ext = ext.lstrip('.') | 85 ext = ext.lstrip('.') |
83 out_ext = self.extensions[ext] | 86 out_ext = self.extensions[ext] |