changeset 203:29165f2f315d

processing: More powerful syntax to specify pipeline processors. The syntax now supports `* -foo -bar` to load all processors except `foo` and `bar`.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 15 Jan 2015 22:54:59 -0800
parents cd049786c008
children f98451237371
files piecrust/processing/base.py
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/processing/base.py	Thu Jan 15 22:53:32 2015 -0800
+++ b/piecrust/processing/base.py	Thu Jan 15 22:54:59 2015 -0800
@@ -24,6 +24,9 @@
 PRIORITY_LAST = 1
 
 
+split_processor_names_re = re.compile(r'[ ,]+')
+
+
 class Processor(object):
     PROCESSOR_NAME = None
 
@@ -145,7 +148,22 @@
             return self.processors
 
         if isinstance(authorized_names, str):
-            authorized_names = authorized_names.split(',')
+            authorized_names = split_processor_names_re.split(authorized_names)
+
+        procs = []
+        has_star = '*' in authorized_names
+        for p in self.processors:
+            for name in authorized_names:
+                if name == p.PROCESSOR_NAME:
+                    procs.append(p)
+                    break
+                if name == ('-%s' % p.PROCESSOR_NAME):
+                    break
+            else:
+                if has_star:
+                    procs.append(p)
+        return procs
+
         return list(filter(
             lambda p: p.PROCESSOR_NAME in authorized_names,
             self.processors))