Changeset 216
- Timestamp:
- 11/05/07 23:20:44
- Files:
-
- trunk/geniusql/logic.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/geniusql/logic.py
r214 r216 284 284 if isinstance(func, dict): 285 285 func = _filter_func(**func) 286 earlybind = False 286 # It might be tempting to set earlybind to False, since 287 # we've hand-generated our func, but we need to change 288 # e.g. lambda: True from a Global to a Const so we don't 289 # end up with the ast: Name('True'). 287 290 self.func = func 288 291 lp = astwalk.LambdaParser(func, env=builtins, reduce=earlybind) … … 380 383 381 384 def _filter_func(**kwargs): 382 items = kwargs.items() 385 """Return a new function object from the given kwargs. 386 387 The new function will be of the form: 388 lambda x: k1 == v1 and k2 == v2... 389 390 unless kwargs is empty, in which case it will be: 391 lambda x: True 392 """ 393 if not kwargs: 394 return lambda x: True 395 383 396 co = [] 384 397 kwlen = len(kwargs) … … 398 411 co.append(83) 399 412 400 items = [('x', None)] + items 401 names, consts = zip(*items) 413 if sys.version_info >= (2, 5): 414 # 2.5 doesn't include arguments in co_names anymore 415 names = tuple(kwargs.keys()) 416 else: 417 names = tuple(['x'] + kwargs.keys()) 418 consts = tuple([None] + kwargs.values()) 402 419 403 420 # Form code object and function.
