From 1c1f4b7dbf21685c1cdefeb0a8dd91a86760c1a3 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Wed, 16 Jan 2013 13:16:16 -0500 Subject: [PATCH] lunchtime fix --- eg/pkginfo.hy | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/eg/pkginfo.hy b/eg/pkginfo.hy index 9f86c12..781b29d 100644 --- a/eg/pkginfo.hy +++ b/eg/pkginfo.hy @@ -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"))