m'fn kwargs
This commit is contained in:
parent
81820abace
commit
87b602fc9f
3
AUTHORS
3
AUTHORS
@ -7,4 +7,5 @@ I'd also like to thank the following people:
|
||||
- Kragen Sitaker:
|
||||
Major thanks goes to Kragen on helping me work through some of the
|
||||
namespacing crap. I think the majority of the approach taken now
|
||||
with expressions' eval bits is his doing in one way or another.
|
||||
with expressions' eval bits for modfaker is his doing in one
|
||||
way or another. Thank you!
|
||||
|
@ -17,4 +17,3 @@ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
@ -2,13 +2,8 @@
|
||||
; Copyright (c) Paul Tagliamonte, in sofar as any of this is at all
|
||||
; copyrightable.
|
||||
|
||||
(import ["sunlight"])
|
||||
(import "sunlight")
|
||||
|
||||
|
||||
(foreach
|
||||
(kwapply (sunlight.openstates.legislators) {"state" "ma"})
|
||||
(fn [x] (print [
|
||||
(get x "first_name")
|
||||
(get x "last_name")
|
||||
(get x "party")
|
||||
])))
|
||||
(for [x (kwapply (sunlight.openstates.legislators) {"state" "ma"})]
|
||||
(print x))
|
||||
|
@ -123,6 +123,7 @@ class AST27Converter(object):
|
||||
|
||||
"doseq": self._ast_for,
|
||||
"for": self._ast_for,
|
||||
"kwapply": self._ast_kwapply,
|
||||
}
|
||||
|
||||
def _def(self, node):
|
||||
@ -138,6 +139,20 @@ class AST27Converter(object):
|
||||
)
|
||||
return ret
|
||||
|
||||
def _ast_kwapply(self, node):
|
||||
i = node.get_invocation()
|
||||
args = i['args']
|
||||
fn = args.pop(0)
|
||||
kwargs = args.pop(0)
|
||||
ret = self.render(fn)
|
||||
ret.keywords = [
|
||||
ast.keyword(
|
||||
arg=str(x),
|
||||
value=self.render(kwargs[x])
|
||||
) for x in kwargs
|
||||
]
|
||||
return ret
|
||||
|
||||
def _ast_while(self, node):
|
||||
i = node.get_invocation()
|
||||
args = i['args']
|
||||
|
Loading…
Reference in New Issue
Block a user