;;; $Id: packages_profile,v 1.2 2006/03/29 11:24:56 lioka Exp $ -*- scheme -*-

(define *packages-profile-file*
  "/var/cache/alterator/packages-profile.scm")

(define *profiles*
  (or (and (access? *packages-profile-file* R_OK)
           (with-input-from-file *packages-profile-file* read))
      '()))

(define (car-list x) (list (car x)))

(object
 #f
 ((list self objects options)
  (if (null? objects)
      (map car-list *profiles*)
      (map (lambda (x)
             (append (list (car x))
                     (alist->plist (cdr x))))
           (or (assoc-ref *profiles* (sure-string (car objects))) '()))))
 ((read self objects options)
  (alist->plist
   (or (assoc-ref (or (assoc-ref *profiles* (sure-string (car objects))) '())
                  (string-join (map sure-string (cdr objects)) "/"))
       '()))))
