Skip to content

Instantly share code, notes, and snippets.

@kana
Created November 18, 2010 10:35
Show Gist options
  • Save kana/704841 to your computer and use it in GitHub Desktop.
Save kana/704841 to your computer and use it in GitHub Desktop.
(use srfi-19)
(use util.match)
(define (read-file path)
(define (calculate-key object)
(match-let ([(_ _ id _ ...) object])
id))
(let1 d (make-hash-table 'eqv?)
(call-with-input-file
path
(lambda (p)
(let loop ([object (read p)])
(unless (eof-object? object)
(hash-table-put! d (calculate-key object) object)
(loop (read p))))))
d))
(define (epoch->mt-datetime epoch)
(date->string (make-time time-utc 0 epoch) "~m/~d/~Y ~r"))
(define (body-format-karetta->html body)
; FIXME: NIY
body
)
(define (main args)
(match-let1 (_ article-list-file article-data-list-file) args
(let ([article-dict (read-file article-list-file)]
[article-data-dict (read-file article-data-list-file)])
(hash-table-for-each article-dict
(lambda (_key article)
(match-let* ([(_ _ _ _ alist) article]
[author "foo"] ; FIXME: NIY
[title "foo"] ; FIXME: NIY
[ctime (assq 'ctime alist)]
[body "foo"]) ; FIXME: NIY
(format #t "AUTHOR: ~a\n" author)
(format #t "TITLE: ~a\n" title)
(format #t "CONVERT BREAKS: ~a\n" 0)
(format #t "DATE: ~a\n" (epoch->mt-datetime ctime))
(format #t "STATUS: Publish\n")
(format #t "-----\n")
(format #t "BODY:\n")
(display (body-format-karetta->html body))
(format #t "\n")
(format #t "-----\n")
(format #t "--------\n")
)))
))
0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment