src/reportlab/pdfbase/pdfpattern.py
branchpy33
changeset 3721 0c93dd8ff567
parent 3317 7cc62d990f32
child 3794 398ea04239b5
equal deleted inserted replaced
3720:7a059dde5bf5 3721:0c93dd8ff567
    25         from types import StringType, InstanceType
    25         from types import StringType, InstanceType
    26         toptypes = (StringType, InstanceType)
    26         toptypes = (StringType, InstanceType)
    27         for x in pattern_sequence:
    27         for x in pattern_sequence:
    28             if type(x) not in toptypes:
    28             if type(x) not in toptypes:
    29                 if len(x)!=1:
    29                 if len(x)!=1:
    30                     raise ValueError, "sequence elts must be strings or singletons containing strings: "+repr(x)
    30                     raise ValueError("sequence elts must be strings or singletons containing strings: "+repr(x))
    31                 if type(x[0]) is not StringType:
    31                 if type(x[0]) is not StringType:
    32                     raise ValueError, "Singletons must contain strings or instances only: "+repr(x[0])
    32                     raise ValueError("Singletons must contain strings or instances only: "+repr(x[0]))
    33     def __setitem__(self, item, value):
    33     def __setitem__(self, item, value):
    34         self.arguments[item] = value
    34         self.arguments[item] = value
    35     def __getitem__(self, item):
    35     def __getitem__(self, item):
    36         return self.arguments[item]
    36         return self.arguments[item]
    37     def format(self, document):
    37     def format(self, document):
    46                 L.append( x.format(document) )
    46                 L.append( x.format(document) )
    47             else:
    47             else:
    48                 name = x[0]
    48                 name = x[0]
    49                 value = arguments.get(name, None)
    49                 value = arguments.get(name, None)
    50                 if value is None:
    50                 if value is None:
    51                     raise ValueError, "%s value not defined" % repr(name)
    51                     raise ValueError("%s value not defined" % repr(name))
    52                 if type(value) is InstanceType:
    52                 if type(value) is InstanceType:
    53                     #L.append( value.format(document) )
    53                     #L.append( value.format(document) )
    54                     L.append(format(value, document))
    54                     L.append(format(value, document))
    55                 else:
    55                 else:
    56                     L.append( str(value) )
    56                     L.append( str(value) )