hy/eg/sunlight/party-count.hy

25 lines
570 B
Hy
Raw Normal View History

2013-03-15 18:00:28 +01:00
#!/usr/bin/env hy
;; Copyright (c) Paul R. Tagliamonte <paultag@debian.org>, 2013 under the terms
;; of the Expat license, a copy of which you have should have recieved with
;; the source.
2013-03-15 18:00:28 +01:00
(import sys)
(import [sunlight [openstates]]
[collections [Counter]])
2013-03-15 18:00:28 +01:00
(def *state* (get sys.argv 1))
(defn get-legislators [state]
2014-01-22 21:38:53 +01:00
(apply openstates.legislators [] {"state" state}))
2013-03-15 18:00:28 +01:00
(defn get-party-breakdown [state]
(Counter (map
(lambda [x] (get x "party"))
(get-legislators state))))
2013-03-15 18:00:28 +01:00
(print *state* "-" (get-party-breakdown *state*))