Adding in another trivial example
This commit is contained in:
parent
723cf75f73
commit
e2ff4a447f
3
bin/hy
3
bin/hy
@ -6,7 +6,8 @@ import sys
|
|||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
from hy.importer import import_file_to_module
|
from hy.importer import import_file_to_module
|
||||||
import_file_to_module("__main__", sys.argv[1])
|
sys.argv.pop(0)
|
||||||
|
import_file_to_module("__main__", sys.argv[0])
|
||||||
sys.exit(0) # right?
|
sys.exit(0) # right?
|
||||||
|
|
||||||
|
|
||||||
|
22
eg/sunlight/party-count.hy
Executable file
22
eg/sunlight/party-count.hy
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env hy
|
||||||
|
; let's check out the party breakdown for a state
|
||||||
|
|
||||||
|
(import sys)
|
||||||
|
(import-from sunlight openstates)
|
||||||
|
(import-from collections Counter)
|
||||||
|
|
||||||
|
|
||||||
|
(def *state* (get sys.argv 1))
|
||||||
|
|
||||||
|
|
||||||
|
(defn get-legislators [state]
|
||||||
|
(kwapply (.legislators openstates) {"state" state}))
|
||||||
|
|
||||||
|
|
||||||
|
(defn get-party-breakdown [state]
|
||||||
|
(Counter (map
|
||||||
|
(lambda [x](get x "party"))
|
||||||
|
(get-legislators state))))
|
||||||
|
|
||||||
|
|
||||||
|
(print *state* "-" (get-party-breakdown *state*))
|
Loading…
Reference in New Issue
Block a user