Skip to content

Commit

Permalink
lunchtime fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Tagliamonte committed Jan 16, 2013
1 parent 5426989 commit 1c1f4b7
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions eg/pkginfo.hy
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,25 @@


(defn parse-rfc-822 [inpu]
"Split an RFC 822 payload up. Doesn't handle comments or multi-entries"
(do (def keys {})
(def key None)
(def val None)
(for [x (.splitlines inpu)]
(if (>= (.find x ":") 0)
(def key None)
(def val None)
(for [x (.splitlines inpu)]
(if (!= x "")
(if (!= (index x 0) " ")
(do (def kv (.split x ":" 1))
(def key (.strip (index kv 0)))
(set-index keys key (.strip (index kv 1))))
(set-index keys key (+ (index keys key) "\n" (.strip x)))))
(dict keys)))
(def key (.strip (index kv 0)))
(set-index keys key (.strip (index kv 1))))
(set-index keys key (+ (index keys key) "\n" (.strip x))))))
(dict keys)))


(defn get-info [package]
"Get info on a Debian package"
(parse-rfc-822 (.show apt-cache 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 package "is a(n)" descr)
(print "")
(print package "is a(n)" (index data "Description-en"))

0 comments on commit 1c1f4b7

Please sign in to comment.