[FIX]XML Base : fix unicode / str py2/3 difference
This commit is contained in:
parent
d5884da16b
commit
24fc3f4807
@ -42,8 +42,10 @@
|
|||||||
(cond [(string? children) (setv (. parent text) children)]
|
(cond [(string? children) (setv (. parent text) children)]
|
||||||
[(instance? XMLDictElement children
|
[(instance? XMLDictElement children
|
||||||
(do
|
(do
|
||||||
(setv attrs (dfor [k v] (.items (. children attrs)) [(unicode k) (unicode v)])
|
(if-python2
|
||||||
new-parent (.SubElement ET parent (. children tag) attrs)
|
(setv attrs (dfor [k v] (.items (. children attrs)) [(unicode k) (unicode v)]))
|
||||||
|
(setv attrs (dfor [k v] (.items (. children attrs)) [(str k) (str v)])))
|
||||||
|
(setv new-parent (.SubElement ET parent (. children tag) attrs)
|
||||||
subchildren (.children children))
|
subchildren (.children children))
|
||||||
(when subchildren) (xmlchild new-parent subchildren)))]
|
(when subchildren) (xmlchild new-parent subchildren)))]
|
||||||
[(instance? list children) (list( map (partial xmlchild parent) children))]
|
[(instance? list children) (list( map (partial xmlchild parent) children))]
|
||||||
@ -52,8 +54,9 @@
|
|||||||
(defn xmln [&optional [tag ""] [attrs {}] [children []]]
|
(defn xmln [&optional [tag ""] [attrs {}] [children []]]
|
||||||
"XMLDictElement building from dict object, with defaults"
|
"XMLDictElement building from dict object, with defaults"
|
||||||
(when (instance? list attrs) (setv children attrs attrs {}))
|
(when (instance? list attrs) (setv children attrs attrs {}))
|
||||||
(setv xmldictel (partial XMLDictElement tag attrs))
|
(setv xmldictel (partial XMLDictElement tag attrs)
|
||||||
(when (instance? unicode children) (return (xmldictel [children])))
|
inst-str? (if-python2 (instance? unicode children) (instance? str children)))
|
||||||
|
(when inst-str? (return (xmldictel [children])))
|
||||||
(when (instance? list children) (return (xmldictel children)))
|
(when (instance? list children) (return (xmldictel children)))
|
||||||
(raise (TypeError "Invalid arguments for xmln")))
|
(raise (TypeError "Invalid arguments for xmln")))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user