[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)]
|
||||
[(instance? XMLDictElement children
|
||||
(do
|
||||
(setv attrs (dfor [k v] (.items (. children attrs)) [(unicode k) (unicode v)])
|
||||
new-parent (.SubElement ET parent (. children tag) attrs)
|
||||
(if-python2
|
||||
(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))
|
||||
(when subchildren) (xmlchild new-parent subchildren)))]
|
||||
[(instance? list children) (list( map (partial xmlchild parent) children))]
|
||||
@ -52,8 +54,9 @@
|
||||
(defn xmln [&optional [tag ""] [attrs {}] [children []]]
|
||||
"XMLDictElement building from dict object, with defaults"
|
||||
(when (instance? list attrs) (setv children attrs attrs {}))
|
||||
(setv xmldictel (partial XMLDictElement tag attrs))
|
||||
(when (instance? unicode children) (return (xmldictel [children])))
|
||||
(setv xmldictel (partial XMLDictElement tag attrs)
|
||||
inst-str? (if-python2 (instance? unicode children) (instance? str children)))
|
||||
(when inst-str? (return (xmldictel [children])))
|
||||
(when (instance? list children) (return (xmldictel children)))
|
||||
(raise (TypeError "Invalid arguments for xmln")))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user