Changeset 5319:35d850990f23 in livinglogic.python.xist

Show
Ignore:
Timestamp:
02/06/13 20:03:06 (7 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Allow mixing enhanced generators and normal functions in CallFunc/CallMeth?.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/ul4c.py

    r5313 r5319  
    2323 
    2424 
    25 import re, datetime, urllib.parse as urlparse, json, collections, locale, itertools, random, datetime, unicodedata 
     25import re, types, datetime, urllib.parse as urlparse, json, collections, locale, itertools, random, datetime, unicodedata 
    2626 
    2727import antlr3 
     
    20172017        if self.remkwargs is not None: 
    20182018            kwargs.update((yield from self.remkwargs.eval(keepws, vars))) 
    2019         return (yield from obj(*args, **kwargs)) 
     2019        result = obj(*args, **kwargs) 
     2020        if isinstance(result, types.GeneratorType): 
     2021            return (yield from result) 
     2022        else: 
     2023            return result 
    20202024 
    20212025    def ul4ondump(self, encoder): 
     
    21452149        if self.remkwargs is not None: 
    21462150            kwargs.update((yield from self.remkwargs.eval(keepws, vars))) 
    2147         return (yield from self.methods[self.methname](obj, *args, **kwargs)) 
     2151        result = self.methods[self.methname](obj, *args, **kwargs) 
     2152        if isinstance(result, types.GeneratorType): 
     2153            return (yield from result) 
     2154        else: 
     2155            return result 
    21482156 
    21492157    def ul4ondump(self, encoder): 
     
    33133321 
    33143322    def __call__(self, **vars): 
    3315         yield from () 
    33163323        return self.template(**collections.ChainMap(vars, self.vars)) 
    33173324