"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Cheetah/FileUtils.py" between
cheetah3-3.2.1.tar.gz and cheetah3-3.2.2.tar.gz

About: Cheetah3 is a template engine and code generation tool for e.g. for Web development or Java, SQL, LaTeX, form email ... (written in Python).

FileUtils.py  (cheetah3-3.2.1):FileUtils.py  (cheetah3-3.2.2)
from glob import glob from glob import glob
import os import os
import os.path import os.path
import re import re
from tempfile import mktemp from tempfile import NamedTemporaryFile
from Cheetah.compat import string_type from Cheetah.compat import string_type
def _escapeRegexChars( def _escapeRegexChars(
txt, escapeRE=re.compile(r'([\$\^\*\+\.\?\{\}\[\]\(\)\|\\])')): txt, escapeRE=re.compile(r'([\$\^\*\+\.\?\{\}\[\]\(\)\|\\])')):
return escapeRE.sub(r'\\\1', txt) return escapeRE.sub(r'\\\1', txt)
def findFiles(*args, **kw): def findFiles(*args, **kw):
"""Recursively find all the files matching a glob pattern. """Recursively find all the files matching a glob pattern.
This function is a wrapper around the FileFinder class. See its docstring This function is a wrapper around the FileFinder class. See its docstring
skipping to change at line 240 skipping to change at line 240
self._pattern = pattern = self._regex.pattern self._pattern = pattern = self._regex.pattern
self._files = files self._files = files
self._results = {} self._results = {}
self._recordResults = recordResults self._recordResults = recordResults
# see if we should use pgrep to do the file matching # see if we should use pgrep to do the file matching
self._usePgrep = False self._usePgrep = False
if (os.popen3('pgrep')[2].read()).startswith('Usage:'): if (os.popen3('pgrep')[2].read()).startswith('Usage:'):
# now check to make sure pgrep understands the pattern # now check to make sure pgrep understands the pattern
tmpFile = mktemp() tmpFile = NamedTemporaryFile()
open(tmpFile, 'w').write('#') tmpFile.write('#')
if not (os.popen3('pgrep "' + pattern + '" ' + tmpFile)[2].read()): if not (os.popen3(
'pgrep "' + pattern + '" ' + tmpFile.name)[2].read()):
# it didn't print an error msg so we're ok # it didn't print an error msg so we're ok
self._usePgrep = True self._usePgrep = True
os.remove(tmpFile) tmpFile.close() # Will be automatically removed on close
self._run() self._run()
def results(self): def results(self):
return self._results return self._results
def _run(self): def _run(self):
regex = self._regex regex = self._regex
subber = self._subDispatcher subber = self._subDispatcher
usePgrep = self._usePgrep usePgrep = self._usePgrep
 End of changes. 3 change blocks. 
5 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)