Changeset 5335:2eac802a9505 in livinglogic.python.xist

Show
Ignore:
Timestamp:
02/10/13 09:47:54 (6 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Add str method to AST (using True for keepws). Enhance Error message.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/ul4c.py

    r5331 r5335  
    152152        if isinstance(self.location, (Template, TemplateClosure)): 
    153153            if self.location.name is not None: 
    154                 return "in template {!r}".format(self.location.name) 
     154                return "in template named {}".format(self.location.name) 
    155155            else: 
    156156                return "in unnamed template" 
    157157        elif isinstance(self.location, Tag): 
    158             return "in {}".format(self.location.location) 
     158            return "in tag {}".format(self.location.location) 
    159159        elif isinstance(self.location, AST): 
    160             return "in {}".format("".join(self.location._str(0, True))) 
     160            return "in expression {}".format(self.location) 
    161161        else: 
    162162            return "in {}".format(self.location) 
     
    278278    def _repr_pretty_(self, p, cycle): 
    279279        p.text(repr(self)) 
     280 
     281    def __str__(self): 
     282        return "".join(self._str(0, True)) # We don't know the ``keepws`` value, use ``True`` instead 
    280283 
    281284    def _formatop(self, op):