lunchtime fix

This commit is contained in:
Paul Tagliamonte 2013-01-16 13:16:16 -05:00
parent 54269898fc
commit 1c1f4b7dbf

View File

@ -8,36 +8,25 @@
(defn parse-rfc-822 [inpu] (defn parse-rfc-822 [inpu]
"Split an RFC 822 payload up. Doesn't handle comments or multi-entries"
(do (def keys {}) (do (def keys {})
(def key None) (def key None)
(def val None) (def val None)
(for [x (.splitlines inpu)] (for [x (.splitlines inpu)]
(if (>= (.find x ":") 0) (if (!= x "")
(if (!= (index x 0) " ")
(do (def kv (.split x ":" 1)) (do (def kv (.split x ":" 1))
(def key (.strip (index kv 0))) (def key (.strip (index kv 0)))
(set-index keys key (.strip (index kv 1)))) (set-index keys key (.strip (index kv 1))))
(set-index keys key (+ (index keys key) "\n" (.strip x))))) (set-index keys key (+ (index keys key) "\n" (.strip x))))))
(dict keys))) (dict keys)))
(defn get-info [package] (defn get-info [package]
"Get info on a Debian package"
(parse-rfc-822 (.show apt-cache package))) (parse-rfc-822 (.show apt-cache package)))
(def data (get-info package)) (def data (get-info package))
(defn get-line [data key]
"Get the first line if a multi-line key"
(index (.split (index data key) "\n") 0))
(if (in "Description" data)
(def descr (get-line data "Description"))
(def descr (get-line data "Description-en")))
(print "The maintainer for" package "is" (index data "Maintainer")) (print "The maintainer for" package "is" (index data "Maintainer"))
(print package "is a(n)" descr) (print "")
(print package "is a(n)" (index data "Description-en"))