Mercurial > piecrust2
comparison piecrust/processing/base.py @ 5:474c9882decf
Upgrade to Python 3.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 11 Aug 2014 22:36:47 -0700 |
parents | f485ba500df3 |
children | 617191dec18e |
comparison
equal
deleted
inserted
replaced
4:7dc71c2dc9a8 | 5:474c9882decf |
---|---|
2 import time | 2 import time |
3 import shutil | 3 import shutil |
4 import os.path | 4 import os.path |
5 import logging | 5 import logging |
6 import threading | 6 import threading |
7 from Queue import Queue, Empty | 7 from queue import Queue, Empty |
8 from piecrust.chefutil import format_timed | 8 from piecrust.chefutil import format_timed |
9 from piecrust.processing.tree import (ProcessingTreeBuilder, | 9 from piecrust.processing.tree import (ProcessingTreeBuilder, |
10 ProcessingTreeRunner, STATE_DIRTY, print_node) | 10 ProcessingTreeRunner, STATE_DIRTY, print_node) |
11 from piecrust.records import Record | 11 from piecrust.records import Record |
12 | 12 |
181 | 181 |
182 if src_dir_or_file is not None: | 182 if src_dir_or_file is not None: |
183 # Process only the given path. | 183 # Process only the given path. |
184 # Find out if this source directory is in a mount point. | 184 # Find out if this source directory is in a mount point. |
185 base_dir = self.app.root_dir | 185 base_dir = self.app.root_dir |
186 for name, path in self.mounts.iteritems(): | 186 for name, path in self.mounts.items(): |
187 if src_dir_or_file[:len(path)] == path: | 187 if src_dir_or_file[:len(path)] == path: |
188 base_dir = path | 188 base_dir = path |
189 | 189 |
190 ctx = ProcessingContext(base_dir, queue, record) | 190 ctx = ProcessingContext(base_dir, queue, record) |
191 logger.debug("Initiating processing pipeline on: %s" % src_dir_or_file) | 191 logger.debug("Initiating processing pipeline on: %s" % src_dir_or_file) |
198 # Process everything. | 198 # Process everything. |
199 ctx = ProcessingContext(self.app.root_dir, queue, record) | 199 ctx = ProcessingContext(self.app.root_dir, queue, record) |
200 logger.debug("Initiating processing pipeline on: %s" % self.app.root_dir) | 200 logger.debug("Initiating processing pipeline on: %s" % self.app.root_dir) |
201 self.processDirectory(ctx, self.app.root_dir) | 201 self.processDirectory(ctx, self.app.root_dir) |
202 ctx.is_multi_mount = True | 202 ctx.is_multi_mount = True |
203 for name, path in self.mounts.iteritems(): | 203 for name, path in self.mounts.items(): |
204 mount_ctx = ProcessingContext(path, queue, record) | 204 mount_ctx = ProcessingContext(path, queue, record) |
205 logger.debug("Initiating processing pipeline on: %s" % path) | 205 logger.debug("Initiating processing pipeline on: %s" % path) |
206 self.processDirectory(mount_ctx, path) | 206 self.processDirectory(mount_ctx, path) |
207 | 207 |
208 # Wait on all workers. | 208 # Wait on all workers. |
323 else: | 323 else: |
324 escaped_pat = (re.escape(pat) | 324 escaped_pat = (re.escape(pat) |
325 .replace(r'\*', r'[^/\\]*') | 325 .replace(r'\*', r'[^/\\]*') |
326 .replace(r'\?', r'[^/\\]')) | 326 .replace(r'\?', r'[^/\\]')) |
327 re_patterns.append(escaped_pat) | 327 re_patterns.append(escaped_pat) |
328 return map(lambda p: re.compile(p), re_patterns) | 328 return [re.compile(p) for p in re_patterns] |
329 | 329 |
330 | 330 |
331 def re_matchany(filename, patterns): | 331 def re_matchany(filename, patterns): |
332 for pattern in patterns: | 332 for pattern in patterns: |
333 if pattern.match(filename): | 333 if pattern.match(filename): |