summaryrefslogtreecommitdiff
path: root/bin/reportlab/pdfbase/pdfpattern.py
diff options
context:
space:
mode:
authorpinky <>2007-01-07 21:24:58 +0000
committerpinky <>2007-01-07 21:24:58 +0000
commit23387d6a5c8094521ec9e3bed1e455a63c267cd9 (patch)
tree94ccc7f0b72e193eb61cc71da32b865a39d574b9 /bin/reportlab/pdfbase/pdfpattern.py
parent44d01beae781bd248604e0f98228a50e5e86aa41 (diff)
Removed reportlab -> 2.0
Better report on timesheets bzr revid: pinky-f7e72504718a6a358300c76ac783f3eb37406dbd
Diffstat (limited to 'bin/reportlab/pdfbase/pdfpattern.py')
-rw-r--r--bin/reportlab/pdfbase/pdfpattern.py59
1 files changed, 0 insertions, 59 deletions
diff --git a/bin/reportlab/pdfbase/pdfpattern.py b/bin/reportlab/pdfbase/pdfpattern.py
deleted file mode 100644
index 0ba62c9bed6..00000000000
--- a/bin/reportlab/pdfbase/pdfpattern.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""
-helper for importing pdf structures into a ReportLab generated document
-"""
-from reportlab.pdfbase.pdfdoc import format
-
-import string
-
-class PDFPattern:
- __RefOnly__ = 1
- def __init__(self, pattern_sequence, **keywordargs):
- """
- Description of a kind of PDF object using a pattern.
-
- Pattern sequence should contain strings or singletons of form [string].
- Strings are literal strings to be used in the object.
- Singletons are names of keyword arguments to include.
- Keyword arguments can be non-instances which are substituted directly in string conversion,
- or they can be object instances in which case they should be pdfdoc.* style
- objects with a x.format(doc) method.
- Keyword arguments may be set on initialization or subsequently using __setitem__, before format.
- "constant object" instances can also be inserted in the patterns.
- """
- self.pattern = pattern_sequence
- self.arguments = keywordargs
- from types import StringType, InstanceType
- toptypes = (StringType, InstanceType)
- for x in pattern_sequence:
- if type(x) not in toptypes:
- if len(x)!=1:
- raise ValueError, "sequence elts must be strings or singletons containing strings: "+repr(x)
- if type(x[0]) is not StringType:
- raise ValueError, "Singletons must contain strings or instances only: "+repr(x[0])
- def __setitem__(self, item, value):
- self.arguments[item] = value
- def __getitem__(self, item):
- return self.arguments[item]
- def format(self, document):
- L = []
- arguments = self.arguments
- from types import StringType, InstanceType
- for x in self.pattern:
- tx = type(x)
- if tx is StringType:
- L.append(x)
- elif tx is InstanceType:
- L.append( x.format(document) )
- else:
- name = x[0]
- value = arguments.get(name, None)
- if value is None:
- raise ValueError, "%s value not defined" % repr(name)
- if type(value) is InstanceType:
- #L.append( value.format(document) )
- L.append(format(value, document))
- else:
- L.append( str(value) )
- return string.join(L, "")
-
-