|
Revision 3656, 1.2 kB
(checked in by ksprotte, 4 months ago)
|
whitespace cleanup
|
| Line | |
|---|
| 1 |
(cl-interpol:enable-interpol-syntax) |
|---|
| 2 |
|
|---|
| 3 |
(defun get-geo-coord (pathname) |
|---|
| 4 |
(let ((data (bknr.utils:file-contents pathname :element-type 'character))) |
|---|
| 5 |
(cl-ppcre:regex-replace |
|---|
| 6 |
#?r"Geographic coordinates:.*\n(?:.*\n){10,15}\s*(\d{1,3} \d\d [NS]), (\d{1,3} \d\d [EW])(?:.*\n)*.*Internet country code:.*\n(?:.*\n){10}\s*\.(..)" |
|---|
| 7 |
data |
|---|
| 8 |
(lambda (target-string start end match-start match-end reg-starts reg-ends) |
|---|
| 9 |
(declare (ignore start end match-start match-end)) |
|---|
| 10 |
(labels ((reg (n) |
|---|
| 11 |
(copy-seq (subseq target-string |
|---|
| 12 |
(aref reg-starts n) |
|---|
| 13 |
(aref reg-ends n))))) |
|---|
| 14 |
(return-from get-geo-coord (list (intern (string-upcase (reg 2)) :keyword) |
|---|
| 15 |
(reg 0) |
|---|
| 16 |
(reg 1)))))) |
|---|
| 17 |
(format t "Unmatched: ~A~@[ (~A)~]~%" |
|---|
| 18 |
pathname (ignore-errors (aref (nth-value 1 (cl-ppcre:scan-to-strings "The World Factbook -- (.*)</title>" data)) 0))) |
|---|
| 19 |
nil)) |
|---|
| 20 |
|
|---|
| 21 |
(defun get-geo-coords (directory-pathname) |
|---|
| 22 |
(remove nil (mapcar #'get-geo-coord (directory (merge-pathnames #P"*.html" directory-pathname))))) |
|---|