mirror of
https://github.com/SqrtMinusOne/biome.git
synced 2025-12-11 14:53:02 +03:00
biome-api-data: more consistent parsing
This commit is contained in:
parent
3f1a95cb9c
commit
d18723e76d
2 changed files with 5791 additions and 5760 deletions
11502
biome-api-data.el
11502
biome-api-data.el
File diff suppressed because it is too large
Load diff
|
|
@ -133,11 +133,11 @@
|
||||||
"Replace these variable defintions with the given ones.")
|
"Replace these variable defintions with the given ones.")
|
||||||
|
|
||||||
(defconst biome-api-parse--add-settings
|
(defconst biome-api-parse--add-settings
|
||||||
`((:param . ("elevation" . ((:name . "Elevation")
|
`(((:param . ("elevation" . ((:name . "Elevation")
|
||||||
(:type . float))))
|
(:type . float))))
|
||||||
(:pages . ("Weather Forecast" "DWD ICON" "NOAA GFS & HRRR"
|
(:pages . ("Weather Forecast" "DWD ICON" "NOAA GFS & HRRR"
|
||||||
"MeteoFrance" "ECMWF" "JMA" "MET Norway" "GEM" "Historical Weather"
|
"MeteoFrance" "ECMWF" "JMA" "MET Norway" "GEM" "Historical Weather"
|
||||||
"Ensemble Models"))))
|
"Ensemble Models")))))
|
||||||
|
|
||||||
(defun biome-api-parse--fix-string (string)
|
(defun biome-api-parse--fix-string (string)
|
||||||
"Remove extra spaces and newlines from STRING."
|
"Remove extra spaces and newlines from STRING."
|
||||||
|
|
@ -215,16 +215,15 @@ Return a list of sections as defined by `biome-api-parse--page'."
|
||||||
(lambda (el)
|
(lambda (el)
|
||||||
(and (eq (dom-tag el) 'button)
|
(and (eq (dom-tag el) 'button)
|
||||||
(string-match-p "nav-link" (dom-attr el 'class))))))))
|
(string-match-p "nav-link" (dom-attr el 'class))))))))
|
||||||
(list
|
(cl-loop for (id . name) in pill-names
|
||||||
(cl-loop for (id . name) in pill-names
|
collect `((:name . ,name)
|
||||||
collect `((:name . ,name)
|
(:fields
|
||||||
(:fields
|
. ,(biome-api-parse--page-variables
|
||||||
. ,(biome-api-parse--page-variables
|
;; XXX dom-by-id doesn't work here
|
||||||
;; XXX dom-by-id doesn't work here
|
(car (dom-search
|
||||||
(car (dom-search
|
section
|
||||||
section
|
(lambda (el)
|
||||||
(lambda (el)
|
(string= (dom-attr el 'id) id))))))))))
|
||||||
(string= (dom-attr el 'id) id)))))))))))
|
|
||||||
|
|
||||||
(defun biome-api-parse--page-accordion (section)
|
(defun biome-api-parse--page-accordion (section)
|
||||||
"Parse bootstrap accordion from SECTION.
|
"Parse bootstrap accordion from SECTION.
|
||||||
|
|
@ -251,9 +250,9 @@ Return a list of sections as defined by `biome-api-parse--page'."
|
||||||
|
|
||||||
The return value is as defined by `biome-api-parse--page'."
|
The return value is as defined by `biome-api-parse--page'."
|
||||||
(or (when-let ((accordion (biome-api-parse--page-accordion section)))
|
(or (when-let ((accordion (biome-api-parse--page-accordion section)))
|
||||||
(list (cons :children accordion)))
|
`((:children . ,accordion)))
|
||||||
(when-let ((variables (biome-api-parse--page-variables section)))
|
(when-let ((variables (biome-api-parse--page-variables section)))
|
||||||
(list (cons :fields variables)))))
|
`((:fields . ,variables)))))
|
||||||
|
|
||||||
(defun biome-api-parse--postprocess-extract-section (sections section-name &optional remove)
|
(defun biome-api-parse--postprocess-extract-section (sections section-name &optional remove)
|
||||||
"Extract section with SECTION-NAME from SECTIONS.
|
"Extract section with SECTION-NAME from SECTIONS.
|
||||||
|
|
@ -278,10 +277,10 @@ is removed from the sections list."
|
||||||
(mapcar (lambda (item)
|
(mapcar (lambda (item)
|
||||||
(when (assoc :children item)
|
(when (assoc :children item)
|
||||||
(let ((extracted (biome-api-parse--postprocess-extract-section
|
(let ((extracted (biome-api-parse--postprocess-extract-section
|
||||||
(cadr (assoc :children item))
|
(cdr (assoc :children item))
|
||||||
section-name remove)))
|
section-name remove)))
|
||||||
(when remove
|
(when remove
|
||||||
(setf (cadr (assoc :children item)) (car extracted)) )
|
(setf (cdr (assoc :children item)) (car extracted)) )
|
||||||
(when (cdr extracted)
|
(when (cdr extracted)
|
||||||
(setq models (cdr extracted)))))
|
(setq models (cdr extracted)))))
|
||||||
item)
|
item)
|
||||||
|
|
@ -377,15 +376,17 @@ fields attributes as cdr:
|
||||||
(biome-api-parse--fix-string
|
(biome-api-parse--fix-string
|
||||||
(dom-text (car h2s))))))
|
(dom-text (car h2s))))))
|
||||||
if (string= section-name "Usage License") return (nreverse res)
|
if (string= section-name "Usage License") return (nreverse res)
|
||||||
|
;; if (string= section-name "Hourly Weather Variables") return (nreverse res)
|
||||||
;; Merge different sections with the same name
|
;; Merge different sections with the same name
|
||||||
unless (assoc section-name res)
|
unless (assoc section-name res)
|
||||||
do (push `(,section-name . nil) res)
|
do (push `(,section-name . nil) res)
|
||||||
do (let ((parsed-section (biome-api-parse--section section)))
|
do (let ((parsed-section (biome-api-parse--section section)))
|
||||||
(cl-loop for (kind . data) in parsed-section
|
(cl-loop
|
||||||
unless (assoc kind (cdr (assoc section-name res)))
|
for (kind . data) in parsed-section
|
||||||
do (push `(,kind . nil) (cdr (assoc section-name res)))
|
unless (assoc kind (cdr (assoc section-name res)))
|
||||||
do (setf (cdr (assoc kind (cdr (assoc section-name res))))
|
do (push `(,kind . nil) (cdr (assoc section-name res)))
|
||||||
(cons data (cdr (assoc kind (cdr (assoc section-name res))))))))
|
do (setf (cdr (assoc kind (cdr (assoc section-name res))))
|
||||||
|
(append data (cdr (assoc kind (cdr (assoc section-name res))))))))
|
||||||
finally return (nreverse res))))
|
finally return (nreverse res))))
|
||||||
(biome-api-parse--postprocess sections name)))
|
(biome-api-parse--postprocess sections name)))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue