Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

Commit

Permalink
whitespace fixes, only
Browse files Browse the repository at this point in the history
  • Loading branch information
Buck Golemon committed Feb 9, 2012
1 parent aa26d3f commit c5c9bf1
Show file tree
Hide file tree
Showing 45 changed files with 1,119 additions and 1,119 deletions.
8 changes: 4 additions & 4 deletions SetupConfig.py
Expand Up @@ -8,7 +8,7 @@
author_email = "cheetahtemplate-discuss@lists.sf.net"
url = "http://www.cheetahtemplate.org/"
packages = ['Cheetah',
'Cheetah.Macros',
'Cheetah.Macros',
'Cheetah.Templates',
'Cheetah.Tests',
'Cheetah.Tools',
Expand Down Expand Up @@ -38,11 +38,11 @@
from distutils.core import Extension

ext_modules=[
Extension("Cheetah._namemapper",
Extension("Cheetah._namemapper",
[os.path.join('cheetah', 'c', '_namemapper.c')]),
# Extension("Cheetah._verifytype",
# Extension("Cheetah._verifytype",
# [os.path.join('cheetah', 'c', '_verifytype.c')]),
# Extension("Cheetah._filters",
# Extension("Cheetah._filters",
# [os.path.join('cheetah', 'c', '_filters.c')]),
# Extension('Cheetah._template',
# [os.path.join('cheetah', 'c', '_template.c')]),
Expand Down
12 changes: 6 additions & 6 deletions SetupTools.py
Expand Up @@ -13,7 +13,7 @@
if not os.getenv('CHEETAH_INSTALL_WITHOUT_SETUPTOOLS'):
try:
from setuptools import setup
except ImportError:
except ImportError:
from distutils.core import setup

from distutils.core import Command
Expand Down Expand Up @@ -56,7 +56,7 @@ def build_extension(self, ext):
except ext_errors, x:
raise BuildFailed(x)


class mod_install_data(install_data):
"""A modified version of the disutils install_data command that allows data
files to be included directly in the installed Python package tree.
Expand All @@ -75,11 +75,11 @@ def run (self):
if not self.dry_run:
self.mkpath(self.install_dir)
data_files = self.get_inputs()

for entry in data_files:
if not isinstance(entry, basestring):
raise ValueError('The entries in "data_files" must be strings')

entry = string.join(string.split(entry, '/'), os.sep)
# entry is a filename or glob pattern
if entry.startswith('recursive:'):
Expand All @@ -89,7 +89,7 @@ def run (self):
filenames = findFiles(dir, globPatterns)
else:
filenames = glob.glob(entry)

for filename in filenames:
## generate the dstPath from the filename
# - deal with 'package_dir' translations
Expand All @@ -116,7 +116,7 @@ def run (self):
else:
outfile = dstPath
self.outfiles.append(outfile)

##################################################
## FUNCTIONS ##

Expand Down
18 changes: 9 additions & 9 deletions cheetah/CacheRegion.py
Expand Up @@ -35,7 +35,7 @@ class CacheItem(object):
- refreshTime (timestamp or None) : last time the cache was refreshed
- data (string) : the content of the cache
'''

def __init__(self, cacheItemID, cacheStore):
self._cacheItemID = cacheItemID
self._cacheStore = cacheStore
Expand All @@ -44,7 +44,7 @@ def __init__(self, cacheItemID, cacheStore):

def hasExpired(self):
return (self._expiryTime and time.time() > self._expiryTime)

def setExpiryTime(self, time):
self._expiryTime = time

Expand Down Expand Up @@ -74,14 +74,14 @@ class _CacheDataStoreWrapper(object):
def __init__(self, dataStore, keyPrefix):
self._dataStore = dataStore
self._keyPrefix = keyPrefix

def get(self, key):
return self._dataStore.get(self._keyPrefix+key)

def delete(self, key):
self._dataStore.delete(self._keyPrefix+key)

def set(self, key, val, time=0):
def set(self, key, val, time=0):
self._dataStore.set(self._keyPrefix+key, val, time=time)

class CacheRegion(object):
Expand All @@ -96,7 +96,7 @@ class CacheRegion(object):
memcached API (http://www.danga.com/memcached).
'''
_cacheItemClass = CacheItem

def __init__(self, regionID, templateCacheIdPrefix='', cacheStore=None):
self._isNew = True
self._regionID = regionID
Expand All @@ -110,24 +110,24 @@ def __init__(self, regionID, templateCacheIdPrefix='', cacheStore=None):

def isNew(self):
return self._isNew

def clear(self):
" drop all the caches stored in this cache region "
for cacheItemId in self._cacheItems.keys():
cacheItem = self._cacheItems[cacheItemId]
cacheItem.clear()
del self._cacheItems[cacheItemId]

def getCacheItem(self, cacheItemID):
""" Lazy access to a cacheItem
Try to find a cache in the stored caches. If it doesn't
exist, it's created.
Returns a `CacheItem` instance.
"""
cacheItemID = md5(str(cacheItemID)).hexdigest()

if cacheItemID not in self._cacheItems:
cacheItem = self._cacheItemClass(
cacheItemID=cacheItemID, cacheStore=self._wrappedCacheDataStore)
Expand Down
16 changes: 8 additions & 8 deletions cheetah/CacheStore.py
Expand Up @@ -55,7 +55,7 @@ def replace(self, key, val, time=0):

def delete(self, key):
del self._data[key]

def get(self, key):
(val, exptime) = self._data[key]
if exptime and time.time() > exptime:
Expand All @@ -65,8 +65,8 @@ def get(self, key):
return val

def clear(self):
self._data.clear()
self._data.clear()

class MemcachedCacheStore(AbstractCacheStore):
servers = ('127.0.0.1:11211')
def __init__(self, servers=None, debug=False):
Expand All @@ -79,22 +79,22 @@ def set(self, key, val, time=0):
self._client.set(key, val, time)

def add(self, key, val, time=0):
res = self._client.add(key, val, time)
res = self._client.add(key, val, time)
if not res:
raise Error('a value for key %r is already in the cache'%key)
self._data[key] = (val, time)

def replace(self, key, val, time=0):
res = self._client.replace(key, val, time)
res = self._client.replace(key, val, time)
if not res:
raise Error('a value for key %r is already in the cache'%key)
self._data[key] = (val, time)

def delete(self, key):
res = self._client.delete(key, time=0)
res = self._client.delete(key, time=0)
if not res:
raise KeyError(key)

def get(self, key):
val = self._client.get(key)
if val is None:
Expand All @@ -103,4 +103,4 @@ def get(self, key):
return val

def clear(self):
self._client.flush_all()
self._client.flush_all()
44 changes: 22 additions & 22 deletions cheetah/CheetahWrapper.py
Expand Up @@ -25,7 +25,7 @@

optionDashesRE = re.compile( R"^-{1,2}" )
moduleNameRE = re.compile( R"^[a-zA-Z_][a-zA-Z_0-9]*$" )

def fprintfMessage(stream, format, *args):
if format[-1:] == '^':
format = format[:-1]
Expand Down Expand Up @@ -66,16 +66,16 @@ def usage(usageMessage, errorMessage="", out=sys.stderr):
out.write("*** USAGE ERROR ***: %s\n" % errorMessage)
exitStatus = 1
sys.exit(exitStatus)


WRAPPER_TOP = """\
__ ____________ __
\ \/ \/ /
\/ * * \/ CHEETAH %(Version)s Command-Line Tool
\ | /
\ | /
\ ==----== / by Tavis Rudd <tavis@damnsimple.com>
\__________/ and Mike Orr <sluggoster@gmail.com>
""" % globals()


Expand All @@ -102,7 +102,7 @@ class CheetahWrapper(object):
MAKE_BACKUPS = True
BACKUP_SUFFIX = ".bak"
_templateClass = None
_compilerSettings = None
_compilerSettings = None

def __init__(self):
self.progName = None
Expand Down Expand Up @@ -143,7 +143,7 @@ def main(self, argv=None):
methInitial = methName[0]
if command in (methName, methInitial):
sys.argv[0] += (" " + methName)
# @@MO: I don't necessarily agree sys.argv[0] should be
# @@MO: I don't necessarily agree sys.argv[0] should be
# modified.
meth()
return
Expand Down Expand Up @@ -196,7 +196,7 @@ def parseOpts(self, args):


if opts.print_settings:
print()
print()
print('>> Available Cheetah compiler settings:')
from Cheetah.Compiler import _DEFAULT_COMPILER_SETTINGS
listing = _DEFAULT_COMPILER_SETTINGS
Expand Down Expand Up @@ -290,14 +290,14 @@ def debug(self, format, *args):
"""
if self.opts.debug:
fprintfMessage(sys.stderr, format, *args)

def warn(self, format, *args):
"""Always print a warning message to stderr.
"""
fprintfMessage(sys.stderr, format, *args)

def error(self, format, *args):
"""Always print a warning message to stderr and exit with an error code.
"""Always print a warning message to stderr and exit with an error code.
"""
fprintfMessage(sys.stderr, format, *args)
sys.exit(1)
Expand All @@ -313,13 +313,13 @@ def _fixExts(self):
self.opts.iext = "." + iext
if oext and not oext.startswith("."):
self.opts.oext = "." + oext



def _compileOrFill(self):
C, D, W = self.chatter, self.debug, self.warn
opts, files = self.opts, self.pathArgs
if files == ["-"]:
if files == ["-"]:
self._compileOrFillStdin()
return
elif not files and opts.recurse:
Expand Down Expand Up @@ -404,7 +404,7 @@ def _checkForCollisions(self, bundles):
if isError:
what = self.isCompile and "Compilation" or "Filling"
sys.exit("%s aborted due to collisions" % what)


def _expandSourceFilesWalk(self, arg, dir, files):
"""Recursion extension for .expandSourceFiles().
Expand All @@ -422,13 +422,13 @@ def _expandSourceFilesWalk(self, arg, dir, files):


def _expandSourceFiles(self, files, recurse, addIextIfMissing):
"""Calculate source paths from 'files' by applying the
"""Calculate source paths from 'files' by applying the
command-line options.
"""
C, D, W = self.chatter, self.debug, self.warn
idir = self.opts.idir
iext = self.opts.iext
files = []
files = []
for f in self.pathArgs:
oldFilesLen = len(files)
D("Expanding %s", f)
Expand All @@ -441,7 +441,7 @@ def _expandSourceFiles(self, files, recurse, addIextIfMissing):
raise Error("source file '%s' is a directory" % path)
elif os.path.isfile(path):
files.append(path)
elif (addIextIfMissing and not path.endswith(iext) and
elif (addIextIfMissing and not path.endswith(iext) and
os.path.isfile(pathWithExt)):
files.append(pathWithExt)
# Do not recurse directories discovered by iext appending.
Expand Down Expand Up @@ -511,11 +511,11 @@ def _getTemplateClass(self):
self.error('The value of option --templateAPIClass is invalid\n'
'It must be in the form "module:class", '
'e.g. "Cheetah.Template:Template"')

modname, classname = modname.split(':')

C('using --templateAPIClass=%s:%s'%(modname, classname))

if p >= 0:
mod = getattr(__import__(modname[:p], {}, {}, [modname[p+1:]]), modname[p+1:])
else:
Expand All @@ -539,18 +539,18 @@ def getkws(**kws):
if self.opts.compilerSettingsString:
try:
exec('settings = getkws(%s)'%self.opts.compilerSettingsString)
except:
except:
self.error("There's an error in your --settings option."
"It must be valid Python syntax.\n"
+" --settings='%s'\n"%self.opts.compilerSettingsString
+" %s: %s"%sys.exc_info()[:2]
+" %s: %s"%sys.exc_info()[:2]
)

validKeys = DEFAULT_COMPILER_SETTINGS.keys()
if [k for k in settings.keys() if k not in validKeys]:
self.error(
'The --setting "%s" is not a valid compiler setting name.'%k)

self._compilerSettings = settings
return settings
else:
Expand Down Expand Up @@ -601,7 +601,7 @@ def _compileOrFillBundle(self, b):
#output = str(TemplateClass(file=src, searchList=self.searchList))
tclass = TemplateClass.compile(file=src, compilerSettings=compilerSettings)
output = str(tclass(searchList=self.searchList))

if bak:
shutil.copyfile(dst, bak)
if dstDir and not os.path.exists(dstDir):
Expand All @@ -615,7 +615,7 @@ def _compileOrFillBundle(self, b):
f = open(dst, 'w')
f.write(output)
f.close()


# Called when invoked as `cheetah`
def _cheetah():
Expand Down

0 comments on commit c5c9bf1

Please sign in to comment.