Skip to content

Commit

Permalink
Added has_key
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Aug 4, 1998
1 parent ef56852 commit 9c4350b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pDocumentTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
__doc__='''Python implementations of document template some features
$Id: pDocumentTemplate.py,v 1.13 1998/05/14 16:27:49 jim Exp $'''
__version__='$Revision: 1.13 $'[11:-2]
$Id: pDocumentTemplate.py,v 1.14 1998/08/04 13:54:04 jim Exp $'''
__version__='$Revision: 1.14 $'[11:-2]

import regex, string, sys
import string, sys
from string import join

StringType=type('')
Expand Down Expand Up @@ -169,6 +169,13 @@ def __getitem__(self,key,call=1,
except (AttributeError,TypeError): pass
return v

def has_key(self,key):
try:
v=self.dicts[key]
except KeyError:
return 0
return 1

getitem=__getitem__

def render_blocks(blocks, md):
Expand Down Expand Up @@ -230,6 +237,9 @@ def render_blocks(blocks, md):
##############################################################################
#
# $Log: pDocumentTemplate.py,v $
# Revision 1.14 1998/08/04 13:54:04 jim
# Added has_key
#
# Revision 1.13 1998/05/14 16:27:49 jim
# Optimized TemplateDict __getitem__ by removing some exception usage
# and by adding test to short circuit rendering of common simple objects
Expand Down

0 comments on commit 9c4350b

Please sign in to comment.