diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..e07d119
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "python.linting.enabled": false,
+ "python.pythonPath": "/usr/bin/python3.9"
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..72493e0
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,25 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "push_to_VM",
+ "type": "shell",
+ "command": "./push_to_vmachine",
+ "problemMatcher": []
+ },
+ {
+ "label": "revert_VM",
+ "type": "shell",
+ "command": "./revert_changes_to_vmachine",
+ "problemMatcher": []
+ },
+ {
+ "label": "push_to_VM_py3",
+ "type": "shell",
+ "command": "./push_to_vmachine_py3",
+ "problemMatcher": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/push_to_vmachine b/push_to_vmachine
new file mode 100755
index 0000000..f931c0a
--- /dev/null
+++ b/push_to_vmachine
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+read -r ip < ./../vmachine_ip
+
+cur_dir=${PWD##*/}
+cur_module=${cur_dir:18}
+cur_module_inner=${cur_module//-}
+echo $cur_dir
+echo $cur_module
+echo $cur_module_inner
+echo $ip
+#because this runs on a VM, paths must be absolute
+in=/var/calculate/proj/calculate-utils-3-${cur_module}/pym/calculate/${cur_module_inner}/*
+in_contr=/var/calculate/proj/calculate-utils-3-${cur_module}/pym/calculate/contrib/*
+out=/usr/lib64/python2.7/site-packages/calculate/${cur_module_inner}/
+out_contr=/usr/lib64/python2.7/site-packages/calculate/contrib
+
+set -x
+#VM's IP, hopefully you added the pub key
+ssh root@$ip rsync -e "ssh" --progress root@192.168.122.1:$in $out -r
+ssh root@$ip rsync -e "ssh" --progress root@192.168.122.1:$in_contr $out_contr -r
+set +x
diff --git a/push_to_vmachine_py3 b/push_to_vmachine_py3
new file mode 100755
index 0000000..d6b7667
--- /dev/null
+++ b/push_to_vmachine_py3
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+read -r ip < ./../vmachine_ip
+
+cur_dir=${PWD##*/}
+cur_module=${cur_dir:18}
+cur_module_inner=${cur_module//-}
+echo $cur_dir
+echo $cur_module
+echo $cur_module_inner
+echo $ip
+#because this runs on a VM, paths must be absolute
+#for py3 push it together with contrib
+in=/var/calculate/proj/calculate-utils-3-${cur_module}/pym/calculate/*
+out=/usr/lib/python3.9/site-packages/calculate/
+
+
+set -x
+#VM's IP, hopefully you added the pub key
+ssh root@$ip rsync -e "ssh" --progress root@192.168.122.1:$in $out -r
+set +x
diff --git a/pym/calculate/contrib/suds/__pycache__/__init__.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/__init__.cpython-39.pyc
new file mode 100755
index 0000000..92726ac
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/__init__.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/argparser.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/argparser.cpython-39.pyc
new file mode 100755
index 0000000..be7ac8f
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/argparser.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/builder.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/builder.cpython-39.pyc
new file mode 100755
index 0000000..f16d227
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/builder.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/cache.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/cache.cpython-39.pyc
new file mode 100755
index 0000000..8e18a99
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/cache.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/client.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/client.cpython-39.pyc
new file mode 100755
index 0000000..b66fc2a
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/client.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/metrics.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/metrics.cpython-39.pyc
new file mode 100755
index 0000000..cc7a6f8
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/metrics.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/options.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/options.cpython-39.pyc
new file mode 100755
index 0000000..2ea040a
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/options.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/plugin.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/plugin.cpython-39.pyc
new file mode 100755
index 0000000..a05dd84
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/plugin.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/properties.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/properties.cpython-39.pyc
new file mode 100755
index 0000000..87141f7
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/properties.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/reader.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/reader.cpython-39.pyc
new file mode 100755
index 0000000..b77eff7
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/reader.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/resolver.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/resolver.cpython-39.pyc
new file mode 100755
index 0000000..4677be4
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/resolver.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/servicedefinition.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/servicedefinition.cpython-39.pyc
new file mode 100755
index 0000000..fddf603
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/servicedefinition.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/serviceproxy.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/serviceproxy.cpython-39.pyc
new file mode 100755
index 0000000..ac693dd
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/serviceproxy.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/soaparray.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/soaparray.cpython-39.pyc
new file mode 100755
index 0000000..0e291cd
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/soaparray.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/store.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/store.cpython-39.pyc
new file mode 100755
index 0000000..1e00f3a
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/store.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/sudsobject.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/sudsobject.cpython-39.pyc
new file mode 100755
index 0000000..59156aa
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/sudsobject.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/version.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/version.cpython-39.pyc
new file mode 100755
index 0000000..1a6818e
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/version.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/wsdl.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/wsdl.cpython-39.pyc
new file mode 100755
index 0000000..b8aacd7
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/wsdl.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/__pycache__/wsse.cpython-39.pyc b/pym/calculate/contrib/suds/__pycache__/wsse.cpython-39.pyc
new file mode 100755
index 0000000..ba6e326
Binary files /dev/null and b/pym/calculate/contrib/suds/__pycache__/wsse.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/bindings/__pycache__/__init__.cpython-39.pyc b/pym/calculate/contrib/suds/bindings/__pycache__/__init__.cpython-39.pyc
new file mode 100755
index 0000000..b6c1bed
Binary files /dev/null and b/pym/calculate/contrib/suds/bindings/__pycache__/__init__.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/bindings/__pycache__/binding.cpython-39.pyc b/pym/calculate/contrib/suds/bindings/__pycache__/binding.cpython-39.pyc
new file mode 100755
index 0000000..0b62644
Binary files /dev/null and b/pym/calculate/contrib/suds/bindings/__pycache__/binding.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/bindings/__pycache__/document.cpython-39.pyc b/pym/calculate/contrib/suds/bindings/__pycache__/document.cpython-39.pyc
new file mode 100755
index 0000000..eaae99c
Binary files /dev/null and b/pym/calculate/contrib/suds/bindings/__pycache__/document.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/bindings/__pycache__/multiref.cpython-39.pyc b/pym/calculate/contrib/suds/bindings/__pycache__/multiref.cpython-39.pyc
new file mode 100755
index 0000000..75db122
Binary files /dev/null and b/pym/calculate/contrib/suds/bindings/__pycache__/multiref.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/bindings/__pycache__/rpc.cpython-39.pyc b/pym/calculate/contrib/suds/bindings/__pycache__/rpc.cpython-39.pyc
new file mode 100755
index 0000000..a3a9fe7
Binary files /dev/null and b/pym/calculate/contrib/suds/bindings/__pycache__/rpc.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/mx/__pycache__/__init__.cpython-39.pyc b/pym/calculate/contrib/suds/mx/__pycache__/__init__.cpython-39.pyc
new file mode 100755
index 0000000..759c647
Binary files /dev/null and b/pym/calculate/contrib/suds/mx/__pycache__/__init__.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/mx/__pycache__/appender.cpython-39.pyc b/pym/calculate/contrib/suds/mx/__pycache__/appender.cpython-39.pyc
new file mode 100755
index 0000000..7f04f0e
Binary files /dev/null and b/pym/calculate/contrib/suds/mx/__pycache__/appender.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/mx/__pycache__/basic.cpython-39.pyc b/pym/calculate/contrib/suds/mx/__pycache__/basic.cpython-39.pyc
new file mode 100755
index 0000000..922dfc5
Binary files /dev/null and b/pym/calculate/contrib/suds/mx/__pycache__/basic.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/mx/__pycache__/core.cpython-39.pyc b/pym/calculate/contrib/suds/mx/__pycache__/core.cpython-39.pyc
new file mode 100755
index 0000000..9f8e474
Binary files /dev/null and b/pym/calculate/contrib/suds/mx/__pycache__/core.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/mx/__pycache__/encoded.cpython-39.pyc b/pym/calculate/contrib/suds/mx/__pycache__/encoded.cpython-39.pyc
new file mode 100755
index 0000000..a6476fe
Binary files /dev/null and b/pym/calculate/contrib/suds/mx/__pycache__/encoded.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/mx/__pycache__/literal.cpython-39.pyc b/pym/calculate/contrib/suds/mx/__pycache__/literal.cpython-39.pyc
new file mode 100755
index 0000000..f1c5182
Binary files /dev/null and b/pym/calculate/contrib/suds/mx/__pycache__/literal.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/mx/__pycache__/typer.cpython-39.pyc b/pym/calculate/contrib/suds/mx/__pycache__/typer.cpython-39.pyc
new file mode 100755
index 0000000..213e7c3
Binary files /dev/null and b/pym/calculate/contrib/suds/mx/__pycache__/typer.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/sax/__pycache__/__init__.cpython-39.pyc b/pym/calculate/contrib/suds/sax/__pycache__/__init__.cpython-39.pyc
new file mode 100755
index 0000000..06da30a
Binary files /dev/null and b/pym/calculate/contrib/suds/sax/__pycache__/__init__.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/sax/__pycache__/attribute.cpython-39.pyc b/pym/calculate/contrib/suds/sax/__pycache__/attribute.cpython-39.pyc
new file mode 100755
index 0000000..a60c05e
Binary files /dev/null and b/pym/calculate/contrib/suds/sax/__pycache__/attribute.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/sax/__pycache__/date.cpython-39.pyc b/pym/calculate/contrib/suds/sax/__pycache__/date.cpython-39.pyc
new file mode 100755
index 0000000..dfe59eb
Binary files /dev/null and b/pym/calculate/contrib/suds/sax/__pycache__/date.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/sax/__pycache__/document.cpython-39.pyc b/pym/calculate/contrib/suds/sax/__pycache__/document.cpython-39.pyc
new file mode 100755
index 0000000..5c94d2c
Binary files /dev/null and b/pym/calculate/contrib/suds/sax/__pycache__/document.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/sax/__pycache__/element.cpython-39.pyc b/pym/calculate/contrib/suds/sax/__pycache__/element.cpython-39.pyc
new file mode 100755
index 0000000..eca5667
Binary files /dev/null and b/pym/calculate/contrib/suds/sax/__pycache__/element.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/sax/__pycache__/enc.cpython-39.pyc b/pym/calculate/contrib/suds/sax/__pycache__/enc.cpython-39.pyc
new file mode 100755
index 0000000..b62f604
Binary files /dev/null and b/pym/calculate/contrib/suds/sax/__pycache__/enc.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/sax/__pycache__/parser.cpython-39.pyc b/pym/calculate/contrib/suds/sax/__pycache__/parser.cpython-39.pyc
new file mode 100755
index 0000000..e617739
Binary files /dev/null and b/pym/calculate/contrib/suds/sax/__pycache__/parser.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/sax/__pycache__/text.cpython-39.pyc b/pym/calculate/contrib/suds/sax/__pycache__/text.cpython-39.pyc
new file mode 100755
index 0000000..7ca45d3
Binary files /dev/null and b/pym/calculate/contrib/suds/sax/__pycache__/text.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/transport/__pycache__/__init__.cpython-39.pyc b/pym/calculate/contrib/suds/transport/__pycache__/__init__.cpython-39.pyc
new file mode 100755
index 0000000..c19802a
Binary files /dev/null and b/pym/calculate/contrib/suds/transport/__pycache__/__init__.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/transport/__pycache__/http.cpython-39.pyc b/pym/calculate/contrib/suds/transport/__pycache__/http.cpython-39.pyc
new file mode 100755
index 0000000..0f5395a
Binary files /dev/null and b/pym/calculate/contrib/suds/transport/__pycache__/http.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/transport/__pycache__/https.cpython-39.pyc b/pym/calculate/contrib/suds/transport/__pycache__/https.cpython-39.pyc
new file mode 100755
index 0000000..804c912
Binary files /dev/null and b/pym/calculate/contrib/suds/transport/__pycache__/https.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/transport/__pycache__/options.cpython-39.pyc b/pym/calculate/contrib/suds/transport/__pycache__/options.cpython-39.pyc
new file mode 100755
index 0000000..49f3fab
Binary files /dev/null and b/pym/calculate/contrib/suds/transport/__pycache__/options.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/umx/__pycache__/__init__.cpython-39.pyc b/pym/calculate/contrib/suds/umx/__pycache__/__init__.cpython-39.pyc
new file mode 100755
index 0000000..56f0364
Binary files /dev/null and b/pym/calculate/contrib/suds/umx/__pycache__/__init__.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/umx/__pycache__/attrlist.cpython-39.pyc b/pym/calculate/contrib/suds/umx/__pycache__/attrlist.cpython-39.pyc
new file mode 100755
index 0000000..24525de
Binary files /dev/null and b/pym/calculate/contrib/suds/umx/__pycache__/attrlist.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/umx/__pycache__/basic.cpython-39.pyc b/pym/calculate/contrib/suds/umx/__pycache__/basic.cpython-39.pyc
new file mode 100755
index 0000000..8e0157e
Binary files /dev/null and b/pym/calculate/contrib/suds/umx/__pycache__/basic.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/umx/__pycache__/core.cpython-39.pyc b/pym/calculate/contrib/suds/umx/__pycache__/core.cpython-39.pyc
new file mode 100755
index 0000000..58dcf01
Binary files /dev/null and b/pym/calculate/contrib/suds/umx/__pycache__/core.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/umx/__pycache__/encoded.cpython-39.pyc b/pym/calculate/contrib/suds/umx/__pycache__/encoded.cpython-39.pyc
new file mode 100755
index 0000000..67cf2af
Binary files /dev/null and b/pym/calculate/contrib/suds/umx/__pycache__/encoded.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/umx/__pycache__/typed.cpython-39.pyc b/pym/calculate/contrib/suds/umx/__pycache__/typed.cpython-39.pyc
new file mode 100755
index 0000000..dbb84fd
Binary files /dev/null and b/pym/calculate/contrib/suds/umx/__pycache__/typed.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/xsd/__pycache__/__init__.cpython-39.pyc b/pym/calculate/contrib/suds/xsd/__pycache__/__init__.cpython-39.pyc
new file mode 100755
index 0000000..5fdbbf0
Binary files /dev/null and b/pym/calculate/contrib/suds/xsd/__pycache__/__init__.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/xsd/__pycache__/depsort.cpython-39.pyc b/pym/calculate/contrib/suds/xsd/__pycache__/depsort.cpython-39.pyc
new file mode 100755
index 0000000..57c355b
Binary files /dev/null and b/pym/calculate/contrib/suds/xsd/__pycache__/depsort.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/xsd/__pycache__/doctor.cpython-39.pyc b/pym/calculate/contrib/suds/xsd/__pycache__/doctor.cpython-39.pyc
new file mode 100755
index 0000000..2e09c89
Binary files /dev/null and b/pym/calculate/contrib/suds/xsd/__pycache__/doctor.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/xsd/__pycache__/query.cpython-39.pyc b/pym/calculate/contrib/suds/xsd/__pycache__/query.cpython-39.pyc
new file mode 100755
index 0000000..f39b33c
Binary files /dev/null and b/pym/calculate/contrib/suds/xsd/__pycache__/query.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/xsd/__pycache__/schema.cpython-39.pyc b/pym/calculate/contrib/suds/xsd/__pycache__/schema.cpython-39.pyc
new file mode 100755
index 0000000..b9ac2cb
Binary files /dev/null and b/pym/calculate/contrib/suds/xsd/__pycache__/schema.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/xsd/__pycache__/sxbase.cpython-39.pyc b/pym/calculate/contrib/suds/xsd/__pycache__/sxbase.cpython-39.pyc
new file mode 100755
index 0000000..579e2c5
Binary files /dev/null and b/pym/calculate/contrib/suds/xsd/__pycache__/sxbase.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/xsd/__pycache__/sxbasic.cpython-39.pyc b/pym/calculate/contrib/suds/xsd/__pycache__/sxbasic.cpython-39.pyc
new file mode 100755
index 0000000..2a743a1
Binary files /dev/null and b/pym/calculate/contrib/suds/xsd/__pycache__/sxbasic.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds/xsd/__pycache__/sxbuiltin.cpython-39.pyc b/pym/calculate/contrib/suds/xsd/__pycache__/sxbuiltin.cpython-39.pyc
new file mode 100755
index 0000000..f133a78
Binary files /dev/null and b/pym/calculate/contrib/suds/xsd/__pycache__/sxbuiltin.cpython-39.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/__init__.pyc b/pym/calculate/contrib/suds_bak/__init__.pyc
new file mode 100644
index 0000000..abc072b
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/__init__.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/argparser.pyc b/pym/calculate/contrib/suds_bak/argparser.pyc
new file mode 100644
index 0000000..e5d658d
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/argparser.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/bindings/__init__.pyc b/pym/calculate/contrib/suds_bak/bindings/__init__.pyc
new file mode 100644
index 0000000..e557408
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/bindings/__init__.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/bindings/binding.pyc b/pym/calculate/contrib/suds_bak/bindings/binding.pyc
new file mode 100644
index 0000000..002fac8
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/bindings/binding.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/bindings/document.pyc b/pym/calculate/contrib/suds_bak/bindings/document.pyc
new file mode 100644
index 0000000..df7717b
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/bindings/document.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/bindings/multiref.pyc b/pym/calculate/contrib/suds_bak/bindings/multiref.pyc
new file mode 100644
index 0000000..2d58775
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/bindings/multiref.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/bindings/rpc.pyc b/pym/calculate/contrib/suds_bak/bindings/rpc.pyc
new file mode 100644
index 0000000..3158ef7
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/bindings/rpc.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/builder.pyc b/pym/calculate/contrib/suds_bak/builder.pyc
new file mode 100644
index 0000000..cd2b4cb
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/builder.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/cache.pyc b/pym/calculate/contrib/suds_bak/cache.pyc
new file mode 100644
index 0000000..497c5b8
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/cache.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/client.pyc b/pym/calculate/contrib/suds_bak/client.pyc
new file mode 100644
index 0000000..cfcbddb
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/client.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/metrics.pyc b/pym/calculate/contrib/suds_bak/metrics.pyc
new file mode 100644
index 0000000..f406642
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/metrics.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/mx/__init__.pyc b/pym/calculate/contrib/suds_bak/mx/__init__.pyc
new file mode 100644
index 0000000..672f818
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/mx/__init__.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/mx/appender.pyc b/pym/calculate/contrib/suds_bak/mx/appender.pyc
new file mode 100644
index 0000000..406baa6
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/mx/appender.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/mx/basic.pyc b/pym/calculate/contrib/suds_bak/mx/basic.pyc
new file mode 100644
index 0000000..3f450c2
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/mx/basic.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/mx/core.pyc b/pym/calculate/contrib/suds_bak/mx/core.pyc
new file mode 100644
index 0000000..7407ad9
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/mx/core.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/mx/encoded.pyc b/pym/calculate/contrib/suds_bak/mx/encoded.pyc
new file mode 100644
index 0000000..8a57c2e
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/mx/encoded.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/mx/literal.pyc b/pym/calculate/contrib/suds_bak/mx/literal.pyc
new file mode 100644
index 0000000..44d2d3c
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/mx/literal.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/mx/typer.pyc b/pym/calculate/contrib/suds_bak/mx/typer.pyc
new file mode 100644
index 0000000..3d6e554
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/mx/typer.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/options.pyc b/pym/calculate/contrib/suds_bak/options.pyc
new file mode 100644
index 0000000..40214ad
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/options.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/plugin.pyc b/pym/calculate/contrib/suds_bak/plugin.pyc
new file mode 100644
index 0000000..c3789c4
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/plugin.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/properties.pyc b/pym/calculate/contrib/suds_bak/properties.pyc
new file mode 100644
index 0000000..bfaaf1d
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/properties.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/reader.pyc b/pym/calculate/contrib/suds_bak/reader.pyc
new file mode 100644
index 0000000..f41035e
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/reader.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/resolver.pyc b/pym/calculate/contrib/suds_bak/resolver.pyc
new file mode 100644
index 0000000..1485599
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/resolver.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sax/__init__.pyc b/pym/calculate/contrib/suds_bak/sax/__init__.pyc
new file mode 100644
index 0000000..e2eb920
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sax/__init__.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sax/attribute.pyc b/pym/calculate/contrib/suds_bak/sax/attribute.pyc
new file mode 100644
index 0000000..8ff5655
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sax/attribute.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sax/date.pyc b/pym/calculate/contrib/suds_bak/sax/date.pyc
new file mode 100644
index 0000000..0362118
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sax/date.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sax/document.pyc b/pym/calculate/contrib/suds_bak/sax/document.pyc
new file mode 100644
index 0000000..0932b1d
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sax/document.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sax/element.pyc b/pym/calculate/contrib/suds_bak/sax/element.pyc
new file mode 100644
index 0000000..7e9ec7a
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sax/element.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sax/enc.pyc b/pym/calculate/contrib/suds_bak/sax/enc.pyc
new file mode 100644
index 0000000..897ef97
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sax/enc.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sax/parser.pyc b/pym/calculate/contrib/suds_bak/sax/parser.pyc
new file mode 100644
index 0000000..3516c20
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sax/parser.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sax/text.pyc b/pym/calculate/contrib/suds_bak/sax/text.pyc
new file mode 100644
index 0000000..f6cac33
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sax/text.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/servicedefinition.pyc b/pym/calculate/contrib/suds_bak/servicedefinition.pyc
new file mode 100644
index 0000000..29d38ee
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/servicedefinition.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/serviceproxy.pyc b/pym/calculate/contrib/suds_bak/serviceproxy.pyc
new file mode 100644
index 0000000..4676812
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/serviceproxy.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/soaparray.pyc b/pym/calculate/contrib/suds_bak/soaparray.pyc
new file mode 100644
index 0000000..5644beb
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/soaparray.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/store.pyc b/pym/calculate/contrib/suds_bak/store.pyc
new file mode 100644
index 0000000..28fd9b2
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/store.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/sudsobject.pyc b/pym/calculate/contrib/suds_bak/sudsobject.pyc
new file mode 100644
index 0000000..72326aa
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/sudsobject.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/transport/__init__.pyc b/pym/calculate/contrib/suds_bak/transport/__init__.pyc
new file mode 100644
index 0000000..820f726
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/transport/__init__.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/transport/http.pyc b/pym/calculate/contrib/suds_bak/transport/http.pyc
new file mode 100644
index 0000000..ed26bb8
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/transport/http.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/transport/https.pyc b/pym/calculate/contrib/suds_bak/transport/https.pyc
new file mode 100644
index 0000000..2c4d434
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/transport/https.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/transport/options.pyc b/pym/calculate/contrib/suds_bak/transport/options.pyc
new file mode 100644
index 0000000..500e914
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/transport/options.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/umx/__init__.pyc b/pym/calculate/contrib/suds_bak/umx/__init__.pyc
new file mode 100644
index 0000000..a9f958c
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/umx/__init__.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/umx/attrlist.pyc b/pym/calculate/contrib/suds_bak/umx/attrlist.pyc
new file mode 100644
index 0000000..8840971
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/umx/attrlist.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/umx/basic.pyc b/pym/calculate/contrib/suds_bak/umx/basic.pyc
new file mode 100644
index 0000000..2465c10
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/umx/basic.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/umx/core.pyc b/pym/calculate/contrib/suds_bak/umx/core.pyc
new file mode 100644
index 0000000..7259828
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/umx/core.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/umx/encoded.pyc b/pym/calculate/contrib/suds_bak/umx/encoded.pyc
new file mode 100644
index 0000000..3100629
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/umx/encoded.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/umx/typed.pyc b/pym/calculate/contrib/suds_bak/umx/typed.pyc
new file mode 100644
index 0000000..0558cd2
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/umx/typed.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/version.pyc b/pym/calculate/contrib/suds_bak/version.pyc
new file mode 100644
index 0000000..1029c48
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/version.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/wsdl.pyc b/pym/calculate/contrib/suds_bak/wsdl.pyc
new file mode 100644
index 0000000..81772d0
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/wsdl.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/wsse.pyc b/pym/calculate/contrib/suds_bak/wsse.pyc
new file mode 100644
index 0000000..5eaa922
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/wsse.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/xsd/__init__.pyc b/pym/calculate/contrib/suds_bak/xsd/__init__.pyc
new file mode 100644
index 0000000..093e4cc
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/xsd/__init__.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/xsd/depsort.pyc b/pym/calculate/contrib/suds_bak/xsd/depsort.pyc
new file mode 100644
index 0000000..9932d27
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/xsd/depsort.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/xsd/doctor.pyc b/pym/calculate/contrib/suds_bak/xsd/doctor.pyc
new file mode 100644
index 0000000..2bf4857
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/xsd/doctor.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/xsd/query.pyc b/pym/calculate/contrib/suds_bak/xsd/query.pyc
new file mode 100644
index 0000000..58704cf
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/xsd/query.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/xsd/schema.pyc b/pym/calculate/contrib/suds_bak/xsd/schema.pyc
new file mode 100644
index 0000000..56a3503
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/xsd/schema.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/xsd/sxbase.pyc b/pym/calculate/contrib/suds_bak/xsd/sxbase.pyc
new file mode 100644
index 0000000..30dd780
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/xsd/sxbase.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/xsd/sxbasic.pyc b/pym/calculate/contrib/suds_bak/xsd/sxbasic.pyc
new file mode 100644
index 0000000..d3bf658
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/xsd/sxbasic.pyc differ
diff --git a/pym/calculate/contrib/suds_bak/xsd/sxbuiltin.pyc b/pym/calculate/contrib/suds_bak/xsd/sxbuiltin.pyc
new file mode 100644
index 0000000..f136dfc
Binary files /dev/null and b/pym/calculate/contrib/suds_bak/xsd/sxbuiltin.pyc differ
diff --git a/pym/calculate/lib/cl_xml.py b/pym/calculate/lib/cl_xml.py
index 9b963cc..2b36420 100644
--- a/pym/calculate/lib/cl_xml.py
+++ b/pym/calculate/lib/cl_xml.py
@@ -14,37 +14,92 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import xml
-from xml.etree import ElementTree as ET
-import xml.dom.minidom as minidom
-from calculate.lib.utils.text import _u
-try:
- if hasattr(xml, "use_pyxml"):
- xml.use_pyxml()
- from xml import xpath
-except ImportError:
- xpath = None
-
-ET_VERSION = ET.VERSION
+# import lxml
+from lxml import etree as ET
+from copy import deepcopy
+
+# def appendChild(*args, **kwargs):
+# ET._Element.append(*args, **kwargs)
+
+# def display(xml):
+# print(str(ET.tostring(xml, pretty_print=True), encoding="UTF-8"))
+# ET._Element.appendChild = appendChild
+
+
+#backwards compat
+class xpath():
+ @staticmethod
+ def Evaluate(xpath, xml):
+ f = ET.XPath(xpath)
+ return f(xml)
+
+#can't add methods to Cython lib.
+#have to do this the ugly way
+def firstChild(element):
+ # f = ET.XPath("//*[1]")
+ # found = f(element)
+ # print("DEBUG FIRST CHILD")
+ # display(element)
+ # display(found[0])
+ # print("DEBUG FIRST CHILD")
+ # display(element)
+ if(element.text):
+ # print("element has text")
+ # print(element.text)
+ return element
+ if(len(element) == 0):
+ # print("element empty")
+ # print(None)
+ return None
+ # print("element has a child")
+ # print(element[0])
+ return element[0]
+# def firstChild(element):
+# if(element.text):
+# return element.text
+# if(len(element) == 0):
+# return None
+# return element[0]
+
+def insertBefore(elem, new_child, ref_child):
+
+ child_parent = new_child.getparent()
+ if child_parent is not None:
+ child_parent.remove(new_child)
+ if(ref_child is None):
+ elem.append(new_child)
+ ref_child.addprevious(new_child)
+ return new_child
class xmlShare(object):
"""Общий класс для объектов XML, наследуем
"""
- def _createElement(self, doc, tagName, text="", attributes=None):
+ def _createElement(self, doc, tag, text="", attributes=None):
"""Создание нового XML элемента"""
if not isinstance(attributes, dict):
attributes = {}
- element = doc.createElement(tagName)
+ # element = ET.SubElement(doc, tag, attributes)
+ element = ET.Element(tag, attributes)
+ # print(type(element))
+ # print(dir(element))
+ # raise Exception
+ # element = doc.createElement(tag)
+ # print(tag)
+ # print(text)
+ # print(attributes)
if text:
- txtNode = doc.createTextNode(_u(text))
- element.appendChild(txtNode)
- for attr in attributes:
- attribute = doc.createAttribute(attr)
- attribute.nodeValue = attributes[attr]
- element.setAttributeNode(attribute)
+ # txtNode = doc.createTextNode(_u(text))
+ # txtNode = doc.createTextNode(text)
+ # element.append(txtNode)
+ element.text = text
+ # for attr in attributes:
+ # attribute = doc.createAttribute(attr)
+ # attribute.text = attributes[attr]
+ # element.setAttributeNode(attribute)
+ # print(ET.tostring(element, pretty_print=True))
return element
@@ -53,16 +108,19 @@ class xmlNode(xmlShare):
"""
def __init__(self):
- self.node = False
+ self.node = None
- def createNode(self, doc, tagName, text=""):
+ def createNode(self, doc, tag, text=""):
"""Создает XML элемент без аттрибутов"""
- self.node = self._createElement(doc, tagName, text)
+ self.node = self._createElement(doc, tag, text)
return self.node
def getNode(self):
return self.node
+ def toxml(self, pretty_print=True):
+ if(self.node is not None):
+ return ET.tostring(self.node, encoding="UTF-8", pretty_print=pretty_print)
class xmlCaption(object):
"""Класс XML заголовок
@@ -78,13 +136,13 @@ class xmlCaption(object):
tmpNode = xmlNode()
self.caption = tmpNode.createNode(doc, "caption")
nameNode = tmpNode.createNode(doc, "name", name)
- self.caption.appendChild(nameNode)
+ self.caption.append(nameNode)
if action:
actNode = tmpNode.createNode(doc, "action", action)
- self.caption.appendChild(actNode)
+ self.caption.append(actNode)
for q in quotes:
quoteNode = tmpNode.createNode(doc, "quote", q)
- self.caption.appendChild(quoteNode)
+ self.caption.append(quoteNode)
return self.caption
def getCaption(self):
@@ -99,7 +157,7 @@ class xmlField(xmlShare):
def __init__(self):
# XML нода поле
- self.field = False
+ self.field = None
def createField(self, doc, typeField, quotes, name="",
values=(), action=None):
@@ -107,18 +165,22 @@ class xmlField(xmlShare):
self.field = self._createElement(doc, "field", "", {"type": typeField})
if name:
nameNode = self._createElement(doc, "name", name)
- self.field.appendChild(nameNode)
+ self.field.append(nameNode)
for v in values:
valueNode = self._createElement(doc, "value", v)
- self.field.appendChild(valueNode)
+ self.field.append(valueNode)
if action:
actNode = self._createElement(doc, "action", action)
- self.field.appendChild(actNode)
+ self.field.append(actNode)
for q in quotes:
quoteNode = self._createElement(doc, "quote", q)
- self.field.appendChild(quoteNode)
+ self.field.append(quoteNode)
return self.field
+ def toxml(self, pretty_print=True):
+ if(self.field is not None):
+ return ET.tostring(self.field, encoding="UTF-8", pretty_print=pretty_print)
+
class xmlFields(object):
"""Класс, в котором находится список ХМL нод field
@@ -145,18 +207,18 @@ class xmlArea(object):
def __init__(self):
# Область
- self.area = False
+ self.area = None
def createArea(self, doc, xmlCaption, xmlFields):
"""Создание XML области"""
tmpNode = xmlNode()
self.area = tmpNode.createNode(doc, "area")
- if xmlCaption and xmlCaption.getCaption():
- self.area.appendChild(xmlCaption.getCaption())
+ if xmlCaption and xmlCaption.getCaption() is not None:
+ self.area.append(xmlCaption.getCaption())
if xmlFields:
fields = xmlFields.getFields()
for field in fields:
- self.area.appendChild(field)
+ self.area.append(field)
return self.area
@@ -181,6 +243,10 @@ class xmlDoc(object):
# Разделитель разделенных списков - по умолчанию перевод строки "\n"
# self.sepSplitFields = False
+ def toxml(self, pretty_print=True):
+ if(self.doc is not None):
+ return ET.tostring(self.doc, encoding="UTF-8", pretty_print=pretty_print)
+
def createDoc(self, typeDoc, version):
"""Создание нового документа новый документ"""
docTxt = (''
@@ -188,11 +254,23 @@ class xmlDoc(object):
'{type_doc}'
''.format(version=version,
type_doc=typeDoc))
- self.doc = minidom.parseString(docTxt)
- self.root = self.doc.documentElement
+ # self.doc = minidom.parseString(docTxt)
+ # self.root = self.doc.documentElement
+ # self.body = xpath.Evaluate('child::body', self.root)[0]
+
+ self.doc = ET.XML(bytes(bytearray(docTxt, encoding='utf-8')))
+ # self.doc = ET.XML(bytes(docTxt, encoding='utf8'))
+ # print(ET.tostring(self.doc, pretty_print=True))
+ self.root = self.doc
+ # print(ET.tostring(self.root, pretty_print=True))
self.body = xpath.Evaluate('child::body', self.root)[0]
+ # print(ET.tostring(self.doc, pretty_print=True))
+ # print(ET.tostring(self.body, pretty_print=True))
# установка разделителя областей
+
+
self.sepAreas = self.createField("br", [], "", [], False, False)
+
# установка разделителя областей разделенных списков
# self.sepSplitFields = self.createField("br",[],"",[],False,False)
return self.doc
@@ -259,24 +337,24 @@ class xmlDoc(object):
def setActionField(self, xmlField, actionTxt):
"""Устанавливает свойство action для XML поля"""
xmlActions = xpath.Evaluate('child::action', xmlField)
- if xmlActions and xmlActions[0].firstChild:
- xmlActions[0].firstChild.nodeValue = actionTxt
+ if xmlActions and firstChild(xmlActions[0]) is not None:
+ firstChild(xmlActions[0]).text = actionTxt
else:
nodeObj = xmlNode()
newNode = nodeObj.createNode(self.doc, "action", actionTxt)
- xmlField.appendChild(newNode)
+ xmlField.append(newNode)
def setActionArea(self, xmlArea, actionTxt):
"""Устанавливает свойство action для XML области"""
xmlActions = xpath.Evaluate('child::caption/action', xmlArea)
xmlCaptions = xpath.Evaluate('child::caption', xmlArea)
- if xmlActions and xmlActions[0].firstChild:
- xmlActions[0].firstChild.nodeValue = actionTxt
+ if xmlActions and firstChild(xmlActions[0]) is not None:
+ firstChild(xmlActions[0]).text = actionTxt
else:
if xmlCaptions:
nodeObj = xmlNode()
newNode = nodeObj.createNode(self.doc, "action", actionTxt)
- xmlCaptions[0].appendChild(newNode)
+ xmlCaptions[0].append(newNode)
def joinField(self, xmlArea, xmlNewField):
"""Объединяет XML ноду область и XML ноду поле"""
@@ -290,7 +368,7 @@ class xmlDoc(object):
if not fieldsOldComp and typeNewField != "seplist":
if self.getActionField(xmlNewField) != "drop":
self.setActionField(xmlNewField, "append")
- xmlArea.appendChild(xmlNewField)
+ xmlArea.append(xmlNewField)
return True
newFieldsAction = self.getActionField(xmlNewField)
newValues = self.getFieldValues(xmlNewField)
@@ -298,15 +376,15 @@ class xmlDoc(object):
for nodeFieldOld in fieldsOldComp:
if newFieldsAction == "drop":
- if nodeFieldOld.nextSibling and \
+ if nodeFieldOld.getnext() and \
self.getTypeField(
- nodeFieldOld.nextSibling) == "br":
- xmlArea.removeChild(nodeFieldOld.nextSibling)
- elif nodeFieldOld.previousSibling and \
+ nodeFieldOld.getnext()) == "br":
+ xmlArea.remove(nodeFieldOld.getnext())
+ elif nodeFieldOld.getprevious() and \
self.getTypeField(
- nodeFieldOld.previousSibling) == "br":
- xmlArea.removeChild(nodeFieldOld.previousSibling)
- xmlArea.removeChild(nodeFieldOld)
+ nodeFieldOld.getprevious()) == "br":
+ xmlArea.remove(nodeFieldOld.getprevious())
+ xmlArea.remove(nodeFieldOld)
continue
oldValues = self.getFieldValues(nodeFieldOld)
# Сравнение значений переменной шаблона и файла
@@ -335,8 +413,8 @@ class xmlDoc(object):
flagCompareSeplist = True
break
if not flagCompareSeplist:
- nextNode = xmlOldField.nextSibling
- newInsNode = nodeSeplist.cloneNode(True)
+ nextNode = xmlOldField.getnext()
+ newInsNode = deepcopy(nodeSeplist)
self.setActionField(newInsNode, "append")
if nextNode:
@@ -348,7 +426,7 @@ class xmlDoc(object):
False,
"append"))
else:
- newInsNode = nodeSeplist.cloneNode(True)
+ newInsNode = deepcopy(nodeSeplist)
if self.getActionField(newInsNode) == "join":
self.setActionField(newInsNode, "append")
if xmlOldField:
@@ -364,8 +442,8 @@ class xmlDoc(object):
# nodeSeplist.cloneNode(True),
# xmlOldField)
- parentNode = nodeSeplist.parentNode
- parentNode.removeChild(nodeSeplist)
+ parentNode = nodeSeplist.getparent()
+ parentNode.remove(nodeSeplist)
insNodesRepl = []
for newNode, nxtNode, app in insSplLst:
@@ -384,26 +462,25 @@ class xmlDoc(object):
for newNode, nxtNode, app in insNodesRepl:
if app == "insert":
- xmlArea.insertBefore(newNode, nxtNode)
+ insertBefore(xmlArea, newNode, nxtNode)
elif app == "append":
- xmlArea.appendChild(newNode)
+ xmlArea.append(newNode)
if xmlOldField:
- parentNode = xmlOldField.parentNode
+ parentNode = xmlOldField.getparent()
if parentNode and newFieldsAction != "join":
- parentNode.removeChild(xmlOldField)
+ parentNode.remove(xmlOldField)
for newNode, nxtNode, app in appSplLst:
if app == "insert":
- xmlArea.insertBefore(newNode, nxtNode)
+ insertBefore(xmlArea, newNode, nxtNode)
elif app == "append":
- xmlArea.appendChild(newNode)
+ xmlArea.append(newNode)
if not flagCompare and typeNewField != "seplist":
# Устанавливаем action=replace
self.setActionField(xmlNewField, "replace")
# Если параметры поля не сходятся заменяем поле
- xmlArea.replaceChild(xmlNewField.cloneNode(True),
- fieldsOldComp[-1])
+ xmlArea.replace(fieldsOldComp[-1], deepcopy(xmlNewField))
if newFieldsAction == "join":
fieldsOldRemove = []
@@ -415,11 +492,11 @@ class xmlDoc(object):
if actionOldNode == "insert" or actionOldNode == "append":
pass
else:
- if nodeFieldOld.nextSibling and \
+ if nodeFieldOld.getnext() and \
self.getTypeField(
- nodeFieldOld.nextSibling) == "br":
- xmlArea.removeChild(nodeFieldOld.nextSibling)
- xmlArea.removeChild(nodeFieldOld)
+ nodeFieldOld.getnext()) == "br":
+ xmlArea.remove(nodeFieldOld.getnext())
+ xmlArea.remove(nodeFieldOld)
return True
def getSepListToField(self, xmlField):
@@ -431,7 +508,7 @@ class xmlDoc(object):
nameField = self.getNameField(xmlField)
if not nameField:
return []
- parentNode = xmlField.parentNode
+ parentNode = xmlField.getparent()
if parentNode:
fieldsVal = xpath.Evaluate(
"child::field[attribute::type='seplist'][child::name='%s'] " \
@@ -444,11 +521,11 @@ class xmlDoc(object):
"""Удаляет комментарии в XML области"""
fieldNodes = xpath.Evaluate('descendant::field', xmlArea)
for fieldNode in fieldNodes:
- if fieldNode.hasAttribute("type"):
- if fieldNode.getAttribute("type") == "comment" or \
- fieldNode.getAttribute("type") == "br":
- parentNode = fieldNode.parentNode
- parentNode.removeChild(fieldNode)
+ if "type" in fieldNode.keys():
+ if fieldNode.get("type") == "comment" or \
+ fieldNode.get("type") == "br":
+ parentNode = fieldNode.getparent()
+ parentNode.remove(fieldNode)
else:
if self.getActionField(fieldNode) == "drop":
pass
@@ -459,9 +536,18 @@ class xmlDoc(object):
def joinBody(self, baseBody, newBody):
"""Объединяет две области Body"""
+ # print("baseBody")
+ # display(baseBody)
+ # print("newBody")
+ # display(newBody)
newFields = xpath.Evaluate('child::field', newBody)
+ # if(newFields):
+ # print("newFields")
+ # display(newFields[0])
xmlNewAreas = xpath.Evaluate('child::area', newBody)
- for xmlNewArea in xmlNewAreas:
+ for i, xmlNewArea in enumerate(xmlNewAreas):
+ # print("xmlNewArea ", i)
+ # display(xmlNewArea)
self.joinArea(baseBody, xmlNewArea)
joinNewFields = xpath.Evaluate("child::field[child::action='join']",
newBody)
@@ -482,7 +568,7 @@ class xmlDoc(object):
flagNewNodeSeplist = True
nameNewField = self.getNameField(xmNewlField)
if nameNewField:
- if removeNodesDict.has_key(nameNewField):
+ if nameNewField in removeNodesDict:
return removeNodesDict[nameNewField]
else:
oldFields = xpath.Evaluate('child::field', baseNode)
@@ -509,7 +595,7 @@ class xmlDoc(object):
notRemoveNodesDict = {}
for notRemNode in joinNewFields:
nameField = self.getNameField(notRemNode)
- if not notRemoveNodesDict.has_key(nameField):
+ if nameField not in notRemoveNodesDict:
notRemoveNodesDict[nameField] = []
notRemoveNodesDict[nameField].append(notRemNode)
else:
@@ -534,9 +620,9 @@ class xmlDoc(object):
removeNodes = removeNodes[:-2]
for removeNode in removeNodes:
- xmlOldArea.removeChild(removeNode)
+ xmlOldArea.remove(removeNode)
for node in sepListField:
- node.setAttribute("type", "seplist")
+ node.set("type", "seplist")
if not (self.getActionField(node) == "join" or
self.getActionField(node) == "drop"):
self.setActionField(node, "insert")
@@ -544,7 +630,7 @@ class xmlDoc(object):
for node in notSepListField:
if self.getTypeField(node) == "seplist":
self.setActionField(node, "append")
- xmlOldArea.appendChild(node)
+ xmlOldArea.append(node)
else:
self.joinField(xmlOldArea, node)
@@ -554,10 +640,10 @@ class xmlDoc(object):
return False
areaNodes = xpath.Evaluate('descendant::area', xmlArea)
for areaNode in areaNodes:
- prevNode = areaNode.previousSibling
+ prevNode = areaNode.getprevious()
if prevNode:
- parentNode = areaNode.parentNode
- parentNode.insertBefore(self.sepAreas.cloneNode(True),
+ parentNode = areaNode.getparent()
+ insertBefore(parentNode, deepcopy(self.sepAreas),
areaNode)
return True
@@ -575,14 +661,14 @@ class xmlDoc(object):
dictVar = {}
for namesAreaCompare in namesAreaCompareAll:
fields = xpath.Evaluate("child::field/child::name",
- namesAreaCompare.parentNode)
+ namesAreaCompare.getparent())
for fieldName in fields:
- nodeField = fieldName.parentNode
+ nodeField = fieldName.getparent()
fieldValue = xpath.Evaluate("child::value", nodeField)
- name = fieldName.firstChild.nodeValue
+ name = firstChild(fieldName).text
value = ""
- if fieldValue and fieldValue[0].firstChild:
- value = fieldValue[0].firstChild.nodeValue
+ if fieldValue and firstChild(fieldValue[0]):
+ value = firstChild(fieldValue[0]).text
dictVar[name] = value
if not allVars:
break
@@ -600,7 +686,7 @@ class xmlDoc(object):
for areaComp in namesAreaComare:
fieldsVal = xpath.Evaluate(
"child::field[child::name='%s'] "
- % nameField, areaComp.parentNode)
+ % nameField, areaComp.getparent())
if fieldsVal:
break
if not fieldsVal:
@@ -609,8 +695,8 @@ class xmlDoc(object):
fieldsVal[0])
if not fieldValue:
return False
- if fieldValue[0].firstChild:
- return fieldValue[0].firstChild.nodeValue
+ if firstChild(fieldValue[0]):
+ return firstChild(fieldValue[0]).text
else:
return ""
@@ -623,7 +709,7 @@ class xmlDoc(object):
namesAreaComare = xpath.Evaluate(
"child::area/child::caption[child::name='%s']" % nameArea,
xmlArea)
- return map(lambda x: x.parentNode, namesAreaComare)
+ return map(lambda x: x.getparent(), namesAreaComare)
def joinArea(self, baseNode, xmlNewArea):
"""Объединяет область c областью Body (xmlNewArea c baseNode)"""
@@ -632,29 +718,36 @@ class xmlDoc(object):
fieldsRemove = xpath.Evaluate(
"descendant::field[child::action='drop']", xmlNewArea)
for rmNode in fieldsRemove:
- parentNode = rmNode.parentNode
- parentNode.removeChild(rmNode)
+ parentNode = rmNode.getparent()
+ parentNode.remove(rmNode)
captionAreasRemove = xpath.Evaluate(
"descendant::area/child::caption[child::action='drop']",
xmlNewArea)
for rmNodeCapt in captionAreasRemove:
- rmNode = rmNodeCapt.parentNode
- parentNode = rmNode.parentNode
- parentNode.removeChild(rmNode)
+ rmNode = rmNodeCapt.getparent()
+ parentNode = rmNode.getparent()
+ parentNode.remove(rmNode)
self.setActionArea(xmlNewArea, "append")
# Добавляем разделитель областей во вложенные области
areaNodes = xpath.Evaluate('descendant::area', xmlNewArea)
+ # print("DEBUG appendArea")
+ # print(len(areaNodes))
for areaNode in areaNodes:
+ # display(areaNode)
self.setActionArea(areaNode, "append")
- parentNode = areaNode.parentNode
- parentNode.insertBefore(self.sepAreas.cloneNode(True),
+ parentNode = areaNode.getparent()
+ insertBefore(parentNode, deepcopy(self.sepAreas),
areaNode)
- baseNode.appendChild(xmlNewArea)
+ baseNode.append(xmlNewArea)
# Добавляем разделитель областей
- baseNode.insertBefore(self.sepAreas.cloneNode(True), xmlNewArea)
+ insertBefore(baseNode, deepcopy(self.sepAreas), xmlNewArea)
nodesNames = xpath.Evaluate('child::area/caption/name', baseNode)
nodesNewArea = xpath.Evaluate('child::caption/name', xmlNewArea)
+ # print("nodesNames")
+ # print(nodesNames)
+ # print('nodesNewArea')
+ # print(nodesNewArea)
if not nodesNames:
# Добавляем область
if nodesNewArea:
@@ -665,43 +758,58 @@ class xmlDoc(object):
if not nodesNames or not nodesNewArea:
return False
nameArea = ""
- if nodesNewArea[0].firstChild:
- nameArea = nodesNewArea[0].firstChild.nodeValue.strip()
+ if firstChild(nodesNewArea[0]) is not None:
+ # print("HELLO")
+
+ nameArea = firstChild(nodesNewArea[0]).text.strip()
+ # print('nameArea: ', nameArea)
+ # print(firstChild(nodesNewArea[0]))
flagFindArea = False
newAreaAction = None
baseNodes = []
for oName in nodesNames:
+ # print("DEBUG in for oName")
+ # print(oName)
+ # display(oName)
+ # print(firstChild(oName))
newAreaAction = self.getActionArea(xmlNewArea)
- oArea = oName.parentNode.parentNode
+ oArea = oName.getparent().getparent()
oNameTxt = ""
- if oName.firstChild:
- oNameTxt = oName.firstChild.nodeValue
+
+ if firstChild(oName) is not None:
+
+ oNameTxt = firstChild(oName).text
+ # print("BBBBBBBBBB")
+ # print(oNameTxt)
if nameArea == oNameTxt:
flagFindArea = True
# При использовании удаления
if newAreaAction == "drop":
- prevNode = oName.parentNode.parentNode.previousSibling
+ prevNode = oName.getparent().getparent().getprevious()
removePrevNodes = []
while prevNode and self.getTypeField(prevNode) == "br":
removePrevNodes.append(prevNode)
- prevNode = prevNode.previousSibling
+ prevNode = prevNode.getprevious()
for removeNode in removePrevNodes:
- baseNode.removeChild(removeNode)
- baseNode.removeChild(oName.parentNode.parentNode)
+ baseNode.remove(removeNode)
+ baseNode.remove(oName.getparent().getparent())
continue
elif newAreaAction == "replace":
- oldAreaNode = oName.parentNode.parentNode
+ oldAreaNode = oName.getparent().getparent()
newAreaCaption = xpath.Evaluate('child::caption',
xmlNewArea)[0]
oldAreaCaption = xpath.Evaluate('child::caption',
oldAreaNode)[0]
if newAreaCaption and oldAreaCaption:
- xmlNewArea.replaceChild(oldAreaCaption, newAreaCaption)
+ #its was replace(old, new) in legacy code, even though
+ #the func takes (new, old). Mistake, or on purpose?
+ #xmlNewArea.replaceChild(oldAreaCaption, newAreaCaption)
+
+ xmlNewArea.replace(newAreaCaption, oldAreaCaption)
self.setActionArea(xmlNewArea, "replace")
- baseNode.replaceChild(xmlNewArea,
- oldAreaNode)
+ baseNode.replace(oldAreaNode, xmlNewArea)
continue
- baseNodes.append(oName.parentNode.parentNode)
+ baseNodes.append(oName.getparent().getparent())
newFields = xpath.Evaluate('child::field', xmlNewArea)
joinNewFields = xpath.Evaluate(
@@ -710,6 +818,7 @@ class xmlDoc(object):
self.addNewFielsOldArea(newFields, joinNewFields, oArea)
if not flagFindArea:
+ # print("FLAG")
# Добавляем область
if not (newAreaAction == "drop" or newAreaAction == "replace"):
appendArea(baseNode, xmlNewArea)
@@ -722,59 +831,60 @@ class xmlDoc(object):
def joinDoc(self, xmlNewDoc):
"""Объединяет два документа"""
- newRootNode = xmlNewDoc.documentElement
+ newRootNode = xmlNewDoc.getroottree()
newBodyNode = xpath.Evaluate('child::body', newRootNode)[0]
- newImportBodyNode = self.doc.importNode(newBodyNode, True)
+ # newImportBodyNode = self.doc.importNode(newBodyNode, True)
+ newImportBodyNode = deepcopy(newBodyNode)
# Перед объединение области с документом
# удаляем комментарии
+
self.removeComment(newImportBodyNode)
self.joinBody(self.body, newImportBodyNode)
# расставляем BR
self.insertBRtoBody(self.body)
+ # print("final:")
+ # display(self.doc)
+ # print("------------------------")
def getQuoteField(self, xmlField):
"""Выдает текст из поля"""
xmlQuotes = xpath.Evaluate('child::quote', xmlField)
br = ""
- if (xmlField.hasAttribute("type") and
- xmlField.getAttribute("type") == "br"):
+ if (xmlField.get("type") == "br"):
br = "\n"
if xmlQuotes:
field = xmlQuotes[0]
- if field.firstChild:
- return field.firstChild.nodeValue + br
+ if firstChild(field) is not None:
+ return firstChild(field).text + br
return "" + br
def getFieldsArea(self, xmlArea):
"""Выдает потомков XML области"""
xmlFields = []
- childNodes = xmlArea.childNodes
+ childNodes = xmlArea.getchildren()
for node in childNodes:
- if node.nodeType == node.ELEMENT_NODE:
- if node.tagName == "area" or node.tagName == "field":
- xmlFields.append(node)
+ # if node.nodeType == node.ELEMENT_NODE:
+ if node.tag == "area" or node.tag == "field":
+ xmlFields.append(node)
return xmlFields
def getTypeField(self, xmlField):
"""Выдает тип поля"""
- if xmlField.hasAttribute("type"):
- return xmlField.getAttribute("type")
- else:
- return False
+ return xmlField.get("type")
def getNameField(self, xmlField):
"""Выдает имя поля"""
xmlNameFields = xpath.Evaluate('child::name', xmlField)
- if xmlNameFields and xmlNameFields[0].firstChild:
- return xmlNameFields[0].firstChild.nodeValue
+ if xmlNameFields and firstChild(xmlNameFields[0]) is not None:
+ return firstChild(xmlNameFields[0]).text
else:
return False
def getNameArea(self, xmlArea):
"""Выдает имя области"""
xmlNameAreas = xpath.Evaluate('child::caption/name', xmlArea)
- if xmlNameAreas and xmlNameAreas[0].firstChild:
- return xmlNameAreas[0].firstChild.nodeValue
+ if xmlNameAreas and firstChild(xmlNameAreas[0]):
+ return firstChild(xmlNameAreas[0]).text
else:
return False
@@ -785,8 +895,8 @@ class xmlDoc(object):
quotes = []
xmlQuotes = xpath.Evaluate('child::caption/quote', xmlArea)
for node in xmlQuotes:
- if node.firstChild:
- quotes.append(node.firstChild.nodeValue)
+ if firstChild(node) is not None:
+ quotes.append(firstChild(node).text)
if len(quotes) == 0:
quotes.append("")
quotes.append("")
@@ -795,14 +905,14 @@ class xmlDoc(object):
return quotes
for i in xmlAreas:
- if i.tagName == "area":
+ if i.tag == "area":
quotesI = getQuotesArea(i)
startAreaI = quotesI[0]
endAreaI = quotesI[1]
text.append(startAreaI)
xmlFieldsI = self.getFieldsArea(i)
for f in xmlFieldsI:
- if f.tagName == "area":
+ if f.tag == "area":
quotesF = getQuotesArea(f)
startAreaF = quotesF[0]
endAreaF = quotesF[1]
@@ -821,8 +931,8 @@ class xmlDoc(object):
def getActionField(self, xmlField):
"""Выдает свойство action XML поля"""
xmlActions = xpath.Evaluate('child::action', xmlField)
- if xmlActions and xmlActions[0].firstChild:
- return xmlActions[0].firstChild.nodeValue
+ if xmlActions and firstChild(xmlActions[0]) is not None:
+ return firstChild(xmlActions[0]).text
else:
return False
@@ -832,24 +942,24 @@ class xmlDoc(object):
xmlValues = xpath.Evaluate('child::value', xmlField)
if xmlValues:
for node in xmlValues:
- if node.firstChild:
- vals.append(node.firstChild.nodeValue)
+ if firstChild(node) is not None:
+ vals.append(firstChild(node).text)
return vals
def getActionArea(self, xmlArea):
"""Выдает свойство action XML области"""
xmlActions = xpath.Evaluate('child::caption/action', xmlArea)
- if xmlActions and xmlActions[0].firstChild:
- return xmlActions[0].firstChild.nodeValue
+ if xmlActions and firstChild(xmlActions[0]) is not None:
+ return firstChild(xmlActions[0]).text
else:
return False
def delActionNodeArea(self, xmlArea):
"""Удаляет свойство action XML области"""
xmlActions = xpath.Evaluate('child::caption/action', xmlArea)
- if xmlActions and xmlActions[0].firstChild:
- parentNode = xmlActions[0].parentNode
- parentNode.removeChild(xmlActions[0])
+ if xmlActions and firstChild(xmlActions[0]) is not None:
+ parentNode = xmlActions[0].getparent()
+ parentNode.remove(xmlActions[0])
return True
else:
return False
@@ -857,9 +967,9 @@ class xmlDoc(object):
def delActionNodeField(self, xmlField):
"""Удаляет свойство action XML поля"""
xmlActions = xpath.Evaluate('child::action', xmlField)
- if xmlActions and xmlActions[0].firstChild:
- parentNode = xmlActions[0].parentNode
- parentNode.removeChild(xmlActions[0])
+ if xmlActions and firstChild(xmlActions[0]) is not None:
+ parentNode = xmlActions[0].getparent()
+ parentNode.remove(xmlActions[0])
return True
else:
return False
@@ -872,15 +982,15 @@ class xmlDoc(object):
# содержит списки нод полей с одинаковыми именами в одной области
fieldsSeplist = {}
for node in childNodes:
- if node.tagName == "area":
+ if node.tag == "area":
self.postParserListSeplist(node)
else:
fieldName = False
xmlFieldNameNodes = xpath.Evaluate('child::name', node)
- if xmlFieldNameNodes and xmlFieldNameNodes[0].firstChild:
- fieldName = xmlFieldNameNodes[0].firstChild.nodeValue
+ if xmlFieldNameNodes and firstChild(xmlFieldNameNodes[0]):
+ fieldName = firstChild(xmlFieldNameNodes[0]).text
if fieldName:
- if fieldsSeplist.has_key(fieldName):
+ if fieldName in fieldsSeplist:
fieldsSeplist[fieldName].append(node)
else:
fieldsSeplist[fieldName] = []
@@ -888,7 +998,7 @@ class xmlDoc(object):
for listNodes in fieldsSeplist.values():
if len(listNodes) > 1:
for node in listNodes:
- node.setAttribute("type", "seplist")
+ node.set("type", "seplist")
def insertBRtoBody(self, xmlArea):
"""Добавляет необходимые переводы строк
@@ -897,33 +1007,31 @@ class xmlDoc(object):
childNodes = self.getFieldsArea(xmlArea)
# нода BR
fieldXMLBr = self.createField("br", [], "", [], False, False)
+
# Предыдущая нода
- lastNode = False
+ lastNode = None
lenChildNodes = len(childNodes)
for i in range(lenChildNodes):
+ # print(lastNode)
node = childNodes[i]
lastTmpNode = node
# Нода area
- if node.tagName == "area":
+ if node.tag == "area":
if self.getActionArea(node) == "append" or \
self.getActionArea(node) == "join":
self.delActionNodeArea(node)
- if lastNode and lastNode.hasAttribute("type") and \
- lastNode.getAttribute("type") == "br" or \
- lastNode and lastNode.hasAttribute(
- "type") and \
- lastNode.getAttribute(
- "type") == "comment":
+ if lastNode is not None and lastNode.get("type") == "br" or \
+ lastNode is not None and lastNode.get("type") == "comment":
indNext = i + 1
if indNext == lenChildNodes:
- xmlArea.appendChild(fieldXMLBr.cloneNode(True))
+ xmlArea.append(deepcopy(fieldXMLBr))
else:
nextNode = childNodes[indNext]
- lastTmpNode = xmlArea.insertBefore(
- fieldXMLBr.cloneNode(True),
+ lastTmpNode = insertBefore(xmlArea,
+ deepcopy(fieldXMLBr),
nextNode)
else:
- xmlArea.insertBefore(fieldXMLBr.cloneNode(True),
+ insertBefore(xmlArea, deepcopy(fieldXMLBr),
node)
self.insertBRtoBody(node)
# Нода field
@@ -931,23 +1039,18 @@ class xmlDoc(object):
if self.getActionField(node) == "append" or \
self.getActionField(node) == "join":
self.delActionNodeField(node)
- if lastNode and lastNode.hasAttribute("type") and \
- lastNode.getAttribute("type") == "br" or \
- lastNode and lastNode.hasAttribute(
- "type") and \
- lastNode.getAttribute(
- "type") == "comment":
+ if lastNode is not None and lastNode.get("type") == "br" or \
+ lastNode is not None and lastNode.get("type") == "comment":
indNext = i + 1
if indNext == lenChildNodes:
- xmlArea.appendChild(fieldXMLBr.cloneNode(True))
+ xmlArea.append(deepcopy(fieldXMLBr))
else:
nextNode = childNodes[indNext]
- lastTmpNode = xmlArea.insertBefore(
- fieldXMLBr.cloneNode(True),
+ lastTmpNode = insertBefore(xmlArea,
+ deepcopy(fieldXMLBr),
nextNode)
else:
- xmlArea.insertBefore(fieldXMLBr.cloneNode(True),
- node)
+ insertBefore(xmlArea, deepcopy(fieldXMLBr), node)
lastNode = lastTmpNode
def postParserList(self):
@@ -964,31 +1067,32 @@ class xmlDoc(object):
for xmlField in xmlFields:
xmlNames = xpath.Evaluate('child::name', xmlField)
xmlVals = xpath.Evaluate('child::value', xmlField)
- if xmlField.hasAttribute("type") and \
- xmlField.getAttribute("type") == "br":
+ # if xmlField.hasAttribute("type") and \
+ # xmlField.getAttribute("type") == "br":
+ if xmlField.get("type") == "br":
lenBrArea += 1
continue
if not xmlNames and not xmlVals:
flagListXml = False
break
- if xmlNames and xmlNames[0].firstChild and \
- xmlNames[0].firstChild.nodeValue:
+ if xmlNames and firstChild(xmlNames[0]) and \
+ firstChild(xmlNames[0]).text:
flagListXml = False
break
- if not (xmlVals and xmlVals[0].firstChild and
- xmlVals[0].firstChild.nodeValue):
+ if not (xmlVals and firstChild(xmlVals[0]) and
+ firstChild(xmlVals[0]).text):
flagListXml = False
break
else:
- fieldValues.append(xmlVals[0].firstChild.nodeValue)
+ fieldValues.append(firstChild(xmlVals[0]).text)
if lenXmlFields == lenBrArea:
flagListXml = False
if flagListXml:
nameNode = xpath.Evaluate('child::caption/name', xmlArea)[0]
fieldName = ""
- if nameNode.firstChild:
- fieldName = nameNode.firstChild.nodeValue
+ if firstChild(nameNode) is not None:
+ fieldName = firstChild(nameNode).text
listArea = []
self.xmlToText([xmlArea], listArea)
fieldQuote = "".join(listArea)
@@ -1004,8 +1108,8 @@ class xmlDoc(object):
areaAction = self.getActionArea(xmlArea)
if areaAction:
self.setActionField(fieldXML, areaAction)
- parentNode = xmlArea.parentNode
- parentNode.insertBefore(fieldXML, xmlArea)
+ parentNode = xmlArea.getparent()
+ insertBefore(parentNode, fieldXML, xmlArea)
if fieldXMLBr:
- parentNode.insertBefore(fieldXMLBr, xmlArea)
- parentNode.removeChild(xmlArea)
+ insertBefore(parentNode, fieldXMLBr, xmlArea)
+ parentNode.remove(xmlArea)
diff --git a/pym/calculate/lib/format/apache.py b/pym/calculate/lib/format/apache.py
index fd43490..be225ce 100644
--- a/pym/calculate/lib/format/apache.py
+++ b/pym/calculate/lib/format/apache.py
@@ -56,7 +56,7 @@ class apache(bind):
xmlFields = xpath.Evaluate("child::fields", self.docObj.body)
if not (xmlFields and
self.docObj.getTypeField(xmlFields[-1]) == "br"):
- self.docObj.body.appendChild(self.docObj.createField("br",
+ self.docObj.body.append(self.docObj.createField("br",
[], "", [],
False, False))
xmlAreas = xpath.Evaluate("child::area", self.docObj.body)
@@ -64,9 +64,7 @@ class apache(bind):
xmlFields = xpath.Evaluate("child::field", xmlArea)
if not (xmlFields and
self.docObj.getTypeField(xmlFields[-1]) == "br"):
- xmlArea.appendChild(self.docObj.createField("br",
- [], "", [],
- False, False))
+ xmlArea.append(self.docObj.createField("br", [], "", [], False, False))
def join(self, apacheObj):
"""Объединяем конфигурации"""
diff --git a/pym/calculate/lib/format/bind.py b/pym/calculate/lib/format/bind.py
index bd365e3..91d4f25 100644
--- a/pym/calculate/lib/format/bind.py
+++ b/pym/calculate/lib/format/bind.py
@@ -219,14 +219,14 @@ class bind(objShare):
self.createXML(f.fields, areaXMLChild, docObj)
- areaXML.appendChild(areaXMLChild)
+ areaXML.append(areaXMLChild)
else:
self.createXML(f.fields, areaXML, docObj)
if "\n" in f.end:
fieldXMLBr = docObj.createField("br", [],
"", [],
False, False)
- areaXML.appendChild(fieldXMLBr)
+ areaXML.append(fieldXMLBr)
else:
if not f:
continue
@@ -237,19 +237,19 @@ class bind(objShare):
field.value,
field.br,
docObj)
- areaXML.appendChild(fieldXML)
+ areaXML.append(fieldXML)
if field.br[-1] == "\n":
fieldXMLBr = docObj.createField("br", [],
"", [],
False,
False)
- areaXML.appendChild(fieldXMLBr)
+ areaXML.append(fieldXMLBr)
elif field.comment is not False:
fieldXML = docObj.createField("comment",
[field.comment],
"", [],
False, False)
- areaXML.appendChild(fieldXML)
+ areaXML.append(fieldXML)
elif field.br is not False:
brText = field.br.replace("\n", "")
if brText:
@@ -262,14 +262,14 @@ class bind(objShare):
[],
"", [],
False, False)
- areaXML.appendChild(fieldXML)
+ areaXML.append(fieldXML)
if i.header and i.start:
- rootNode.appendChild(areaXML)
+ rootNode.append(areaXML)
if "\n" in i.end:
fieldXMLBr = docObj.createField("br", [], "", [],
False, False)
- rootNode.appendChild(fieldXMLBr)
+ rootNode.append(fieldXMLBr)
else:
fields = self.splitToFields(i)
@@ -278,17 +278,17 @@ class bind(objShare):
fieldXML = self.createFieldTerm(field.name,
field.value,
field.br, docObj)
- rootNode.appendChild(fieldXML)
+ rootNode.append(fieldXML)
if field.br[-1] == "\n":
fieldXMLBr = docObj.createField("br", [], "", [],
False, False)
- rootNode.appendChild(fieldXMLBr)
+ rootNode.append(fieldXMLBr)
elif field.comment is not False:
fieldXML = docObj.createField("comment",
[field.comment],
"", [],
False, False)
- rootNode.appendChild(fieldXML)
+ rootNode.append(fieldXML)
elif field.br is not False:
brText = field.br.replace("\n", "")
if brText:
@@ -298,8 +298,8 @@ class bind(objShare):
else:
fieldXML = docObj.createField('br', [], "", [],
False, False)
- rootNode.appendChild(fieldXML)
- # rootNode.appendChild(areaXML)
+ rootNode.append(fieldXML)
+ # rootNode.append(areaXML)
def textToXML(self):
"""Преобразуем текст в XML"""
diff --git a/pym/calculate/lib/format/dovecot.py b/pym/calculate/lib/format/dovecot.py
index cf84327..9767cac 100644
--- a/pym/calculate/lib/format/dovecot.py
+++ b/pym/calculate/lib/format/dovecot.py
@@ -46,7 +46,7 @@ class dovecot(bind):
if xmlFields and not (
self.docObj.getTypeField(xmlFields[-1]) == "br" or
self.docObj.getTypeField(xmlFields[-1]) == "comment"):
- xmlArea.appendChild(self.docObj.createField("br",
+ xmlArea.append(self.docObj.createField("br",
[], "", [],
False, False))
xmlAreas = xpath.Evaluate("child::area", xmlArea)
diff --git a/pym/calculate/lib/format/generic.py b/pym/calculate/lib/format/generic.py
index 7cbe385..2fd5dfa 100644
--- a/pym/calculate/lib/format/generic.py
+++ b/pym/calculate/lib/format/generic.py
@@ -48,7 +48,7 @@ class objShare(TemplateFormat):
if name[0] == "!":
fieldAction = "drop"
elif name[0] == "+":
- fieldXML.setAttribute("type", "seplist")
+ fieldXML.set("type", "seplist")
fieldAction = "join"
else:
fieldXML = docObj.createField("var",
@@ -83,13 +83,13 @@ class objShare(TemplateFormat):
def getConfig(self, joinChar=""):
"""Выдает конфигурационный файл"""
listConfigTxt = []
- childNodes = self.docObj.getNodeBody().childNodes
+ childNodes = self.docObj.getNodeBody().getchildren()
for node in childNodes:
- if node.nodeType == node.ELEMENT_NODE:
- if node.tagName == "field":
- listConfigTxt.append(self.docObj.getQuoteField(node))
- elif node.tagName == "area":
- self.docObj.xmlToText([node], listConfigTxt)
+ # if node.nodeType == node.ELEMENT_NODE:
+ if node.tag == "field":
+ listConfigTxt.append(self.docObj.getQuoteField(node))
+ elif node.tag == "area":
+ self.docObj.xmlToText([node], listConfigTxt)
return "%s\n" % joinChar.join(listConfigTxt).rstrip("\n ")
def splitToFields(self, txtBloc):
@@ -112,7 +112,6 @@ class objShare(TemplateFormat):
z = 0
lenLines = len(linesBlocTmp)
for i in linesBlocTmp:
-
if self.reComment.split(i)[0]:
findCooment = self.reComment.search(i)
comment = False
diff --git a/pym/calculate/lib/format/kde.py b/pym/calculate/lib/format/kde.py
index 8debbe2..6cef4ee 100644
--- a/pym/calculate/lib/format/kde.py
+++ b/pym/calculate/lib/format/kde.py
@@ -132,11 +132,11 @@ class kde(samba):
area = docObj.createArea()
if areaAction:
docObj.setActionArea(area, areaAction)
- rootNode.appendChild(area)
+ rootNode.append(area)
else:
fieldsNodes = docObj.tmpFields.getFields()
for fieldNode in fieldsNodes:
- rootNode.appendChild(fieldNode)
+ rootNode.append(fieldNode)
docObj.clearTmpFields()
z += 1
return docObj
diff --git a/pym/calculate/lib/format/ldap.py b/pym/calculate/lib/format/ldap.py
index 1434774..a5faf54 100644
--- a/pym/calculate/lib/format/ldap.py
+++ b/pym/calculate/lib/format/ldap.py
@@ -161,7 +161,7 @@ class ldap(samba):
docObj.setActionField(xmlField, "drop")
elif f.name[0] == "+":
# Добавляем уникальное поле
- xmlField.setAttribute("type", "seplist")
+ xmlField.set("type", "seplist")
docObj.setActionField(xmlField, "join")
else:
docObj.createField("var", [f.br.replace("\n", "")],
@@ -175,11 +175,11 @@ class ldap(samba):
area = docObj.createArea()
if areaAction:
docObj.setActionArea(area, areaAction)
- rootNode.appendChild(area)
+ rootNode.append(area)
else:
fieldsNodes = docObj.tmpFields.getFields()
for fieldNode in fieldsNodes:
- rootNode.appendChild(fieldNode)
+ rootNode.append(fieldNode)
docObj.clearTmpFields()
z += 1
return docObj
diff --git a/pym/calculate/lib/format/patch.py b/pym/calculate/lib/format/patch.py
index 066fbde..350df8a 100644
--- a/pym/calculate/lib/format/patch.py
+++ b/pym/calculate/lib/format/patch.py
@@ -16,9 +16,10 @@
import sys
import re
-import xml.dom.minidom
+# import xml.dom.minidom
+from lxml import etree
from calculate.lib.cl_template import TemplateFormat
-
+from calculate.lib.cl_xml import firstChild
from calculate.lib.cl_lang import setLocalTranslate
_ = lambda x: x
@@ -38,7 +39,7 @@ class patch(TemplateFormat):
# Создаем XML документ
self.doc = self.textToXML()
if self.doc:
- self.rootNode = self.doc.documentElement
+ self.rootNode = self.doc.getroottree()
self.reFlags = 0
def textToXML(self):
@@ -50,7 +51,8 @@ class patch(TemplateFormat):
text = ('\n%s'
% self.text)
try:
- self.doc = xml.dom.minidom.parseString(text)
+ # self.doc = xml.dom.minidom.parseString(text)
+ self.doc = etree.XML(bytes(bytearray(text, encoding='utf-8')))
except Exception:
return False
return self.doc
@@ -63,7 +65,7 @@ class patch(TemplateFormat):
def processingFile(self, textConfigFile, rootPath=None, nameFile=None):
"""Обработка конфигурационного файла"""
- if not self.doc:
+ if self.doc is None:
self.setError(_("Failed to convert the text template to XML"))
return False
retTextConfigFile = textConfigFile
@@ -71,54 +73,54 @@ class patch(TemplateFormat):
dataList = []
tagsIndex = 0
regex = False
- for node in self.rootNode.childNodes:
- if node.nodeType == node.ELEMENT_NODE:
- if not node.tagName == tags[tagsIndex]:
- self.setError(_("Incorrect template text"))
- return False
- if tagsIndex == 1:
- tagsIndex = 0
- else:
- tagsIndex += 1
- # регулярное выражение
- if node.tagName == "reg":
- if node.firstChild:
- reText = node.firstChild.nodeValue
- if reText is None:
- textNode = node.toxml().encode("UTF8")
- self.setError(
- _("Incorrect template text") + ": \n" +
- "%s" % textNode)
- return False
- else:
- self.setError(
- _("Incorrect text of template ''"))
- return False
- if not reText.strip():
+ for node in self.rootNode.getchildren():
+ # if node.nodeType == node.ELEMENT_NODE:
+ if not node.tag == tags[tagsIndex]:
+ self.setError(_("Incorrect template text"))
+ return False
+ if tagsIndex == 1:
+ tagsIndex = 0
+ else:
+ tagsIndex += 1
+ # регулярное выражение
+ if node.tag == "reg":
+ if firstChild(node) is not None:
+ reText = firstChild(node).text
+ if reText is None:
+ textNode = node.toxml()
self.setError(
- _("Incorrect text of template '%s'")
- % reText.encode("UTF8"))
+ _("Incorrect template text") + ": \n" +
+ "%s" % textNode)
return False
- try:
- regex = re.compile(reText, self.reFlags)
- except re.error:
+ else:
+ self.setError(
+ _("Incorrect text of template ''"))
+ return False
+ if not reText.strip():
+ self.setError(
+ _("Incorrect text of template '%s'")
+ % reText)
+ return False
+ try:
+ regex = re.compile(reText, self.reFlags)
+ except re.error:
+ self.setError(
+ _("Incorrect text of template '%s'")
+ % reText)
+ return False
+ elif node.tag == "text" and regex:
+ if firstChild(node) is not None:
+ text = firstChild(node).text
+ if text is None:
+ textNode = node.toxml()
self.setError(
- _("Incorrect text of template '%s'").decode('utf-8')
- % reText.encode("UTF8"))
+ _("Incorrect template text") + ": \n" +
+ "%s" % textNode)
return False
- elif node.tagName == "text" and regex:
- if node.firstChild:
- text = node.firstChild.nodeValue
- if text is None:
- textNode = node.toxml().encode("UTF8")
- self.setError(
- _("Incorrect template text") + ": \n" +
- "%s" % textNode)
- return False
- else:
- text = ""
- dataList.append((regex, text.encode('utf-8')))
- regex = False
+ else:
+ text = ""
+ dataList.append((regex, text))
+ regex = False
for regex, text in dataList:
# Замены в тексте конфигурационного файла
retTextConfigFile = regex.sub(text, retTextConfigFile)
diff --git a/pym/calculate/lib/format/plasma.py b/pym/calculate/lib/format/plasma.py
index e30682c..3ed9bdf 100644
--- a/pym/calculate/lib/format/plasma.py
+++ b/pym/calculate/lib/format/plasma.py
@@ -17,7 +17,8 @@
import re
import types
import copy
-from calculate.lib.cl_xml import xpath, xmlDoc
+from calculate.lib.cl_xml import xpath, xmlDoc, firstChild
+from copy import deepcopy
from calculate.lib.cl_template import blocText
from calculate.lib.format.samba import samba
@@ -86,26 +87,25 @@ class xmlDocPlasma(xmlDoc):
fieldsRemove = xpath.Evaluate(
"descendant::field[child::action='drop']", xmlNewArea)
for rmNode in fieldsRemove:
- parentNode = rmNode.parentNode
- parentNode.removeChild(rmNode)
+ parentNode = rmNode.getparent()
+ parentNode.remove(rmNode)
captionAreasRemove = xpath.Evaluate(
"descendant::area/child::caption[child::action='drop']",
xmlNewArea)
for rmNodeCapt in captionAreasRemove:
- rmNode = rmNodeCapt.parentNode
- parentNode = rmNode.parentNode
- parentNode.removeChild(rmNode)
+ rmNode = rmNodeCapt.getparent()
+ parentNode = rmNode.getparent()
+ parentNode.remove(rmNode)
self.setActionArea(xmlNewArea, "append")
# Добавляем разделитель областей во вложенные области
areaNodes = xpath.Evaluate('descendant::area', xmlNewArea)
for areaNode in areaNodes:
self.setActionArea(areaNode, "append")
- parentNode = areaNode.parentNode
- parentNode.insertBefore(self.sepAreas.cloneNode(True),
- areaNode)
- baseNode.appendChild(xmlNewArea)
+ parentNode = areaNode.getparent()
+ parentNode.insertBefore(deepcopy(self.sepAreas), areaNode)
+ baseNode.append(xmlNewArea)
# Добавляем разделитель областей
- baseNode.insertBefore(self.sepAreas.cloneNode(True), xmlNewArea)
+ baseNode.insertBefore(deepcopy(self.sepAreas), xmlNewArea)
nodesNames = xpath.Evaluate('child::area/caption/name', baseNode)
nodesNewArea = xpath.Evaluate('child::caption/name', xmlNewArea)
@@ -119,55 +119,54 @@ class xmlDocPlasma(xmlDoc):
if not nodesNames or not nodesNewArea:
return False
nameArea = ""
- if nodesNewArea[0].firstChild:
- nameArea = nodesNewArea[0].firstChild.nodeValue.strip()
+ if firstChild(nodesNewArea[0]) is not None:
+ nameArea = firstChild(nodesNewArea).text.strip()
flagFindArea = False
baseNodes = []
newAreaAction = None
for oName in nodesNames:
newAreaAction = self.getActionArea(xmlNewArea)
- oArea = oName.parentNode.parentNode
+ oArea = oName.getparent().getparent()
oNameTxt = ""
- if oName.firstChild:
- oNameTxt = oName.firstChild.nodeValue
+ if firstChild(oName) is not None:
+ oNameTxt = firstChild(oName).text
if nameArea == oNameTxt:
flagFindArea = True
# При использовании удаления
if newAreaAction == "drop":
- prevNode = oName.parentNode.parentNode.previousSibling
+ prevNode = oName.getparent().getparent().getprevious()
removePrevNodes = []
while prevNode and self.getTypeField(prevNode) == "br":
removePrevNodes.append(prevNode)
- prevNode = prevNode.previousSibling
+ prevNode = prevNode.getprevious()
for removeNode in removePrevNodes:
- baseNode.removeChild(removeNode)
- baseNode.removeChild(oName.parentNode.parentNode)
+ baseNode.remove(removeNode)
+ baseNode.remove(oName.getparent().getparent())
continue
elif newAreaAction == "replace":
- oldAreaNode = oName.parentNode.parentNode
+ oldAreaNode = oName.getparent().getparent()
newAreaCaption = xpath.Evaluate('child::caption',
xmlNewArea)[0]
oldAreaCaption = xpath.Evaluate('child::caption',
oldAreaNode)[0]
if newAreaCaption and oldAreaCaption:
- xmlNewArea.replaceChild(oldAreaCaption, newAreaCaption)
+ xmlNewArea.replace(newAreaCaption, oldAreaCaption)
self.setActionArea(xmlNewArea, "replace")
- baseNode.replaceChild(xmlNewArea,
- oldAreaNode)
+ baseNode.replace(oldAreaNode, xmlNewArea)
continue
- baseNodes.append(oName.parentNode.parentNode)
+ baseNodes.append(oName.getparent().getparent())
# Заменяем QUOTE
- oldAreaNode = oName.parentNode.parentNode
+ oldAreaNode = oName.getparent().getparent()
oldAreaQuote = xpath.Evaluate('child::caption/quote',
oldAreaNode)[0]
- if oldAreaQuote and not oldAreaQuote.firstChild:
+ if oldAreaQuote and firstChild(oldAreaQuote) is None:
newAreaQuote = xpath.Evaluate('child::caption/quote',
xmlNewArea)[0]
oldAreaCaption = xpath.Evaluate('child::caption',
oldAreaNode)[0]
- if newAreaQuote and oldAreaCaption:
- oldAreaCaption.replaceChild(newAreaQuote, oldAreaQuote)
+ if newAreaQuote is not None and oldAreaCaption is not None:
+ oldAreaCaption.replace(oldAreaQuote, newAreaQuote)
newFields = xpath.Evaluate('child::field', xmlNewArea)
@@ -400,14 +399,14 @@ class plasma(samba):
self.createXML(f.fields, areaXMLChild, docObj)
- areaXML.appendChild(areaXMLChild)
+ areaXML.append(areaXMLChild)
else:
self.createXML(f.fields, areaXML, docObj)
if "\n" in f.end:
fieldXMLBr = docObj.createField("br", [],
"", [],
False, False)
- areaXML.appendChild(fieldXMLBr)
+ areaXML.append(fieldXMLBr)
else:
if not f:
continue
@@ -416,16 +415,16 @@ class plasma(samba):
if field.name is not False:
fieldXML = self.createFieldTerm(
field.name, field.value, field.br, docObj)
- areaXML.appendChild(fieldXML)
+ areaXML.append(fieldXML)
if field.br[-1] == "\n":
fieldXMLBr = docObj.createField(
"br", [], "", [], False, False)
- areaXML.appendChild(fieldXMLBr)
+ areaXML.append(fieldXMLBr)
elif field.comment is not False:
fieldXML = docObj.createField(
"comment", [field.comment], "", [],
False, False)
- areaXML.appendChild(fieldXML)
+ areaXML.append(fieldXML)
elif field.br is not False:
brText = field.br.replace("\n", "")
if brText:
@@ -434,16 +433,16 @@ class plasma(samba):
else:
fieldXML = docObj.createField(
'br', [], "", [], False, False)
- if areaXML and hasattr(areaXML, "appendChild"):
- areaXML.appendChild(fieldXML)
+ if areaXML and hasattr(areaXML, "append"):
+ areaXML.append(fieldXML)
if i.header:
- rootNode.appendChild(areaXML)
+ rootNode.append(areaXML)
if "\n" in i.end:
fieldXMLBr = docObj.createField("br", [],
"", [],
False, False)
- rootNode.appendChild(fieldXMLBr)
+ rootNode.append(fieldXMLBr)
else:
if not i:
@@ -454,15 +453,15 @@ class plasma(samba):
fieldXML = self.createFieldTerm(field.name,
field.value,
field.br, docObj)
- rootNode.appendChild(fieldXML)
+ rootNode.append(fieldXML)
if field.br[-1] == "\n":
fieldXMLBr = docObj.createField("br", [], "", [],
False, False)
- rootNode.appendChild(fieldXMLBr)
+ rootNode.append(fieldXMLBr)
elif field.comment is not False:
fieldXML = docObj.createField(
"comment", [field.comment], "", [], False, False)
- rootNode.appendChild(fieldXML)
+ rootNode.append(fieldXML)
elif field.br is not False:
brText = field.br.replace("\n", "")
if brText:
@@ -471,8 +470,8 @@ class plasma(samba):
else:
fieldXML = docObj.createField(
'br', [], "", [], False, False)
- rootNode.appendChild(fieldXML)
- # rootNode.appendChild(areaXML)
+ rootNode.append(fieldXML)
+ # rootNode.append(areaXML)
def createTxtConfig(self, strHeader, dictVar):
"""Cоздает область с заголовком
@@ -516,8 +515,8 @@ class plasma(samba):
quotes = []
xmlQuotes = xpath.Evaluate('child::caption/quote', xmlArea)
for node in xmlQuotes:
- if node.firstChild:
- quotes.append(node.firstChild.nodeValue)
+ if firstChild(node):
+ quotes.append(firstChild(node).text)
if len(quotes) == 0:
quotes.append("")
quotes.append("")
@@ -529,27 +528,27 @@ class plasma(samba):
for xmlArea in xmlAreas:
# Перед пустой областью и после нее удаляем переводы строк
if getQuotesArea(xmlArea) == ["", ""]:
- if (xmlArea.previousSibling and
+ if (xmlArea.getprevious() and
self.docObj.getTypeField(
- xmlArea.previousSibling) == "br"):
- parentNode = xmlArea.previousSibling.parentNode
- prev_prev_sbl = xmlArea.previousSibling.previousSibling
+ xmlArea.getprevious()) == "br"):
+ parentNode = xmlArea.getprevious().getparent()
+ prev_prev_sbl = xmlArea.getprevious().getprevious()
if (prev_prev_sbl and
self.docObj.getTypeField(
prev_prev_sbl) == "br"):
- parentNode.removeChild(
- xmlArea.previousSibling.previousSibling)
- parentNode.removeChild(xmlArea.previousSibling)
- if (xmlArea.nextSibling and
+ parentNode.remove(
+ xmlArea.getprevious().getprevious())
+ parentNode.remove(xmlArea.getprevious())
+ if (xmlArea.getnext() and
self.docObj.getTypeField(
- xmlArea.nextSibling) == "br"):
- parentNode = xmlArea.nextSibling.parentNode
- next_next_sbl = xmlArea.nextSibling.nextSibling
+ xmlArea.getnext()) == "br"):
+ parentNode = xmlArea.getnext().getparent()
+ next_next_sbl = xmlArea.getnext().getnext()
if (next_next_sbl and
self.docObj.getTypeField(
next_next_sbl) == "br"):
- parentNode.removeChild(xmlArea.nextSibling.nextSibling)
- parentNode.removeChild(xmlArea.nextSibling)
+ parentNode.remove(xmlArea.getnext().getnext())
+ parentNode.remove(xmlArea.getnext())
continue
# Собираем поля в кучку
@@ -558,23 +557,23 @@ class plasma(samba):
childNodes = self.docObj.getFieldsArea(xmlArea)
firstChildArea = xmlChildAreas[0]
- if (firstChildArea.previousSibling and
+ if (firstChildArea.getprevious() and
self.docObj.getTypeField(
- firstChildArea.previousSibling) == "br"):
+ firstChildArea.getprevious()) == "br"):
prev_prev_sbl = (
- firstChildArea.previousSibling.previousSibling)
+ firstChildArea.getprevious().getprevious())
if prev_prev_sbl:
if self.docObj.getTypeField(prev_prev_sbl) == "br":
- firstChildArea = firstChildArea.previousSibling
+ firstChildArea = firstChildArea.getprevious()
flagFoundArea = False
it = 0
lenChild = len(childNodes)
for node in childNodes:
it += 1
- if node.tagName == "area":
+ if node.tag == "area":
flagFoundArea = True
continue
- if flagFoundArea and node.tagName == "field":
+ if flagFoundArea and node.tag == "field":
if self.docObj.getTypeField(node) == "var":
xmlArea.insertBefore(node, firstChildArea)
if it < lenChild:
@@ -585,9 +584,9 @@ class plasma(samba):
firstChildArea)
# Добавление перевода строк в если его нет между полями
if (self.docObj.getTypeField(node) == "var" and
- node.previousSibling and
+ node.getprevious() and
not (self.docObj.getTypeField(
- node.previousSibling) in ("br", "comment"))):
+ node.getprevious()) in ("br", "comment"))):
xmlArea.insertBefore(self.docObj.createField(
"br", [], "", [], False, False), node)
@@ -607,9 +606,9 @@ class plasma(samba):
for node in xmlFields:
# Добавление перевода строк в если его нет между полями
if (self.docObj.getTypeField(node) == "var" and
- node.previousSibling and
+ node.getprevious() and
not (self.docObj.getTypeField(
- node.previousSibling) in ("br", "comment"))):
+ node.getprevious()) in ("br", "comment"))):
xmlArea.insertBefore(self.docObj.createField("br",
[], "", [],
False,
@@ -617,36 +616,36 @@ class plasma(samba):
node)
# Если последним полем BR, удаляем его
if xmlFields and self.docObj.getTypeField(xmlFields[-1]) == "br":
- if not xmlFields[-1].nextSibling:
- xmlArea.removeChild(xmlFields[-1])
+ if not xmlFields[-1].getnext():
+ xmlArea.remove(xmlFields[-1])
# Если предыдущим полем не (BR или комментарий) - добавляем BR
- if (xmlArea.previousSibling and
+ if (xmlArea.getprevious() and
not (self.docObj.getTypeField(
- xmlArea.previousSibling) == "br" or
+ xmlArea.getprevious()) == "br" or
self.docObj.getTypeField(
- xmlArea.previousSibling) == "comment")):
- parentNode = xmlArea.parentNode
+ xmlArea.getprevious()) == "comment")):
+ parentNode = xmlArea.getparent()
parentNode.insertBefore(self.docObj.createField(
"br", [], "", [], False, False), xmlArea)
# Если есть предыдущее поле, и поле предыдущеее предыдущему
# не равно BR или комментарий то добавляем BR
- if xmlArea.previousSibling:
- prPrSibling = xmlArea.previousSibling.previousSibling
+ if xmlArea.getprevious():
+ prPrSibling = xmlArea.getprevious().getprevious()
if (prPrSibling and
not (self.docObj.getTypeField(
prPrSibling) == "br" or
self.docObj.getTypeField(
prPrSibling) == "comment")):
- parentNode = xmlArea.parentNode
+ parentNode = xmlArea.getparent()
parentNode.insertBefore(self.docObj.createField(
"br", [], "", [], False, False), xmlArea)
# Если после есть BR а за ним ничего нет, удаляем BR
- if (xmlArea.nextSibling and
- self.docObj.getTypeField(xmlArea.nextSibling) == "br"):
- if not xmlArea.nextSibling.nextSibling:
- parentNode = xmlArea.nextSibling.parentNode
- parentNode.removeChild(xmlArea.nextSibling)
+ if (xmlArea.getnext() and
+ self.docObj.getTypeField(xmlArea.getnext()) == "br"):
+ if not xmlArea.getnext().getnext():
+ parentNode = xmlArea.getnext().getparent()
+ parentNode.remove(xmlArea.getnext())
def join(self, kdeObj):
"""Объединяем конфигурации"""
diff --git a/pym/calculate/lib/format/procmail.py b/pym/calculate/lib/format/procmail.py
index 1fdaf32..0c6906f 100644
--- a/pym/calculate/lib/format/procmail.py
+++ b/pym/calculate/lib/format/procmail.py
@@ -44,8 +44,8 @@ class procmail(objShare):
for node in xmlFields:
# Добавление перевода строк в если его нет между полями
if (self.docObj.getTypeField(node) == "var" and
- node.previousSibling and
- (self.docObj.getTypeField(node.previousSibling) not in
+ node.getprevious() is not None and
+ (self.docObj.getTypeField(node.getprevious()) not in
("br", "comment"))):
self.docObj.body.insertBefore(self.docObj.createField(
"br", [], "", [], False, False), node)
@@ -99,15 +99,15 @@ class procmail(objShare):
fieldXML = self.createFieldTerm(field.name,
field.value,
field.br, docObj)
- nodeBody.appendChild(fieldXML)
+ nodeBody.append(fieldXML)
if field.br[-1] == "\n":
fieldXMLBr = docObj.createField(
"br", [], "", [], False, False)
- nodeBody.appendChild(fieldXMLBr)
+ nodeBody.append(fieldXMLBr)
elif field.comment is not False:
fieldXML = docObj.createField(
"comment", [field.comment], "", [], False, False)
- nodeBody.appendChild(fieldXML)
+ nodeBody.append(fieldXML)
elif field.br is not False:
brText = field.br.replace("\n", "")
if brText:
@@ -116,7 +116,7 @@ class procmail(objShare):
else:
fieldXML = docObj.createField(
'br', [], "", [], False, False)
- nodeBody.appendChild(fieldXML)
+ nodeBody.append(fieldXML)
return docObj
def join(self, procmailObj):
diff --git a/pym/calculate/lib/format/samba.py b/pym/calculate/lib/format/samba.py
index 4f4f1a4..5ee4e0e 100644
--- a/pym/calculate/lib/format/samba.py
+++ b/pym/calculate/lib/format/samba.py
@@ -53,8 +53,8 @@ class samba(objShare):
if not xmlFields:
removeList.append(xmlArea)
for xmlArea in removeList:
- parentNode = xmlArea.parentNode
- parentNode.removeChild(xmlArea)
+ parentNode = xmlArea.getparent()
+ parentNode.remove(xmlArea)
# Для добавления перевода строки между областями если его нет
xmlAreas = xpath.Evaluate("child::area", self.docObj.body)
@@ -64,9 +64,9 @@ class samba(objShare):
if not (xmlFields and (
self.docObj.getTypeField(xmlFields[-1]) == "br" or
self.docObj.getTypeField(xmlFields[-1]) == "comment")):
- if xmlArea.nextSibling:
- parentNode = xmlArea.parentNode
- nextNode = xmlArea.nextSibling
+ if xmlArea.getnext() is not None:
+ parentNode = xmlArea.getparent()
+ nextNode = xmlArea.getnext()
parentNode.insertBefore(self.docObj.createField(
"br", [], "", [], False, False), nextNode)
# Добавление переводов строк между полями
@@ -74,9 +74,9 @@ class samba(objShare):
for node in xmlFields:
# Добавление перевода строк в если его нет между полями
if (self.docObj.getTypeField(node) == "var" and
- node.previousSibling and
+ node.getprevious() is not None and
not (self.docObj.getTypeField(
- node.previousSibling) in ("br", "comment"))):
+ node.getprevious()) in ("br", "comment"))):
xmlArea.insertBefore(self.docObj.createField(
"br", [], "", [], False, False), node)
@@ -85,7 +85,7 @@ class samba(objShare):
lenBr = 0
removeBrNodes = []
for node in childNodes:
- if (node.tagName == "field" and
+ if (node.tag == "field" and
self.docObj.getTypeField(node) == "br"):
lenBr += 1
if lenBr > 2:
@@ -94,15 +94,15 @@ class samba(objShare):
lenBr = 0
# Удаление
for rmNode in removeBrNodes:
- self.docObj.body.removeChild(rmNode)
+ self.docObj.body.remove(rmNode)
# Если после есть BR а за ним ничего нет, удаляем BR
- if xmlArea:
- if (xmlArea.nextSibling and
- self.docObj.getTypeField(xmlArea.nextSibling) == "br"):
- if not xmlArea.nextSibling.nextSibling:
- parentNode = xmlArea.nextSibling.parentNode
- parentNode.removeChild(xmlArea.nextSibling)
+ if xmlArea is not None:
+ if (xmlArea.getnext() is not None and
+ self.docObj.getTypeField(xmlArea.getnext()) == "br"):
+ if not xmlArea.getnext().getnext():
+ parentNode = xmlArea.getnext().getparent()
+ parentNode.remove(xmlArea.getnext())
def join(self, sambaObj):
"""Объединяем конфигурации"""
@@ -289,11 +289,11 @@ class samba(objShare):
area = docObj.createArea()
if areaAction:
docObj.setActionArea(area, areaAction)
- rootNode.appendChild(area)
+ rootNode.append(area)
else:
fieldsNodes = docObj.tmpFields.getFields()
for fieldNode in fieldsNodes:
- rootNode.appendChild(fieldNode)
+ rootNode.append(fieldNode)
docObj.clearTmpFields()
z += 1
return docObj
diff --git a/pym/calculate/lib/format/xml_gconf.py b/pym/calculate/lib/format/xml_gconf.py
index 39b1e8d..f73f801 100644
--- a/pym/calculate/lib/format/xml_gconf.py
+++ b/pym/calculate/lib/format/xml_gconf.py
@@ -18,10 +18,12 @@ import sys
import time
import re
from calculate.lib.cl_xml import xpath
-import xml.dom.minidom
+# import xml.dom.minidom
+from lxml import etree
from calculate.lib.format.xml_xfce import xml_xfce
from calculate.lib.cl_lang import setLocalTranslate
from collections import Iterable
+from copy import deepcopy
_ = lambda x: x
setLocalTranslate('cl_lib3', sys.modules[__name__])
@@ -71,21 +73,23 @@ class xml_gconf(xml_xfce):
if not self.text.strip():
self.text = ''''''
try:
- self.doc = xml.dom.minidom.parseString(self.text)
+ # self.doc = xml.dom.minidom.parseString(self.text)
+ self.doc = etree.XML(bytes(bytearray(self.text, encoding='utf-8')))
except Exception:
self.setError(_("The template content is not XML"))
return False
- self.rootNode = self.doc.documentElement
- self.bodyNode = self.rootNode
+ self.rootNode = self.doc.getroottree()
+ self.bodyNode = self.rootNode #? a mistake, maybe?
return self.doc
def cmpListsNodesEntry(self, listXmlA, listXmlB):
"""Сравнение содержимого двух списков XML нод"""
def getTextsNodes(listXml):
- for node in (x.cloneNode(True)
- for x in listXml if x.nodeType == x.ELEMENT_NODE):
- if node.hasAttribute("mtime"):
- node.removeAttribute("mtime")
+ for node in (deepcopy(x)
+ for x in listXml):# if x.nodeType == x.ELEMENT_NODE):
+ if "mtime" in node.keys():
+ # node.removeAttribute("mtime")
+ del node.attrib["mtime"]
text = node.toxml()
yield text.replace(" ", "").replace("\t", "").replace("\n", "")
if set(getTextsNodes(listXmlA)) == set(getTextsNodes(listXmlB)):
@@ -97,166 +101,161 @@ class xml_gconf(xml_xfce):
if levelNumber > 1:
return True
xmlNode = xmlNewNode
- childNodes = xmlNode.childNodes
+ childNodes = xmlNode.getchildren()
nextOldNode = xmlOldNode
- if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
- n = xmlNode
- tagName = n.tagName
- nAction = u''
- nType = u''
- nValue = u''
- nSchema = u''
- attrName = ''
- if flagRootNode:
- if not tagName == "gconf":
- self.setError(_("The text is not a valid gconf-XML format \
+ # if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
+ n = xmlNode
+ tagName = n.tag
+ nAction = u''
+ nType = u''
+ nValue = u''
+ nSchema = u''
+ attrName = ''
+ if flagRootNode:
+ if not tagName == "gconf":
+ self.setError(_("The text is not a valid gconf-XML format \
(not found '...')"))
- return False
- flagType = False
- flagValue = False
- flagSchema = False
- else:
- if not tagName == "entry":
- self.setError(_("The text is not a valid gconf-XML format \
+ return False
+ flagType = False
+ flagValue = False
+ flagSchema = False
+ else:
+ if not tagName == "entry":
+ self.setError(_("The text is not a valid gconf-XML format \
(found '<%(tag)s>..%(tag)s>')") % {'tag': tagName})
+ return False
+ if "name" not in n.keys():
+ self.setError(
+ _("Attribute \"name\" not found in the tag entry"))
+ return False
+ flagType = "type" in n.keys()
+ flagValue = False
+ flagSchema = "schema" in n.keys()
+ if flagSchema:
+ nSchema = n.get("schema")
+ if not flagType and not flagSchema:
+ self.setError(
+ _("Attribute \"type\" not found in the tag entry"))
+ return False
+ nName = n.get("name")
+ attrName = u"attribute::name='%s'" % nName
+ if flagType:
+ flagValue = "value" in n.keys()
+ nType = n.get("type")
+ # Проверка правильности аттрибута type
+ if nType not in self.supportEntryTypes:
+ self.setError(_("Incorrect \"type\" attribute "
+ ": ") % nType)
return False
- if not n.hasAttribute("name"):
- self.setError(
- _("Attribute \"name\" not found in the tag entry"))
- return False
- flagType = n.hasAttribute("type")
- flagValue = False
- flagSchema = n.hasAttribute("schema")
- if flagSchema:
- nSchema = n.getAttribute("schema")
- if not flagType and not flagSchema:
- self.setError(
- _("Attribute \"type\" not found in the tag entry"))
+ if flagValue:
+ nValue = n.get("value")
+ if "action" in n.keys():
+ nAction = n.get("action")
+ if nAction not in ("join", "replace", "drop"):
+ textError = _("In the text of the XML template, "
+ "reserved attribute 'action' comes with an "
+ "incorrect value.\n"
+ "Valid values of the 'action' attribute are: "
+ '(action="join", action="replace",'
+ 'action="drop")')
+ self.setError(textError)
+ return False
+ if xmlOldNode.getparent():
+ findAttrStr = ""
+ if attrName:
+ findAttrStr = "[%s]" % attrName
+ findPath = u"child::%s%s" % (tagName, findAttrStr)
+ # Рабочая нода
+ if flagRootNode:
+ workNode = xmlOldNode.getparent()
+ else:
+ workNode = xmlOldNode
+ oldNodes = xpath.Evaluate(findPath, workNode)
+ # По умолчанию - объединение
+ flagJoin = True
+ flagReplace = False
+ flagDrop = False
+ # Замещаем ноду
+ if nType == "string" or nAction == "replace":
+ flagJoin = False
+ flagReplace = True
+ # Замещаем ноду в случае массива
+ elif nType == "list" or nType == "pair":
+ flagJoin = False
+ flagReplace = True
+ # Удаляем ноду
+ elif nAction == "drop":
+ flagJoin = False
+ flagDrop = True
+ if flagRootNode:
+ textError = _('Incorrect action="drop" in '
+ 'the root node')
+ self.setError(textError)
return False
- nName = n.getAttribute("name")
- attrName = u"attribute::name='%s'" % nName
- if flagType:
- flagValue = n.hasAttribute("value")
- nType = n.getAttribute("type")
- # Проверка правильности аттрибута type
- if nType not in self.supportEntryTypes:
- self.setError(_("Incorrect \"type\" attribute "
- ": ") % nType)
- return False
- if flagValue:
- nValue = n.getAttribute("value")
- if n.hasAttribute("action"):
- nAction = n.getAttribute("action")
- if nAction not in ("join", "replace", "drop"):
- textError = _("In the text of the XML template, "
- "reserved attribute 'action' comes with an "
- "incorrect value.\n"
- "Valid values of the 'action' attribute are: "
- '(action="join", action="replace",'
- 'action="drop")')
+ if oldNodes:
+ if len(oldNodes) > 1:
+ textError = _("Ambiguity in this template: the same "
+ "nodes are on a same level")
self.setError(textError)
return False
- if xmlOldNode.parentNode:
- findAttrStr = ""
- if attrName:
- findAttrStr = "[%s]" % attrName
- findPath = u"child::%s%s" % (tagName, findAttrStr)
- # Рабочая нода
- if flagRootNode:
- workNode = xmlOldNode.parentNode
- else:
- workNode = xmlOldNode
- oldNodes = xpath.Evaluate(findPath, workNode)
- # По умолчанию - объединение
- flagJoin = True
- flagReplace = False
- flagDrop = False
- # Замещаем ноду
- if nType == "string" or nAction == "replace":
- flagJoin = False
- flagReplace = True
- # Замещаем ноду в случае массива
- elif nType == "list" or nType == "pair":
- flagJoin = False
- flagReplace = True
- # Удаляем ноду
- elif nAction == "drop":
- flagJoin = False
- flagDrop = True
- if flagRootNode:
- textError = _('Incorrect action="drop" in '
- 'the root node')
- self.setError(textError)
- return False
- if oldNodes:
- if len(oldNodes) > 1:
- textError = _("Ambiguity in this template: the same "
- "nodes are on a same level")
- self.setError(textError)
- return False
- nextOldNode = oldNodes[0]
- # Объединение нод
- if flagJoin:
- if flagType and flagValue:
- flagChange = False
- foundValue = nextOldNode.hasAttribute("value")
- if foundValue:
- oValue = nextOldNode.getAttribute("value")
- if nValue != oValue:
- flagChange = True
- else:
+ nextOldNode = oldNodes[0]
+ # Объединение нод
+ if flagJoin:
+ if flagType and flagValue:
+ flagChange = False
+ if "value" in nextOldNode.keys():
+ oValue = nextOldNode.get("value")
+ if nValue != oValue:
flagChange = True
- if flagChange:
- nextOldNode.setAttribute("mtime",
- self.currentTime)
- nextOldNode.setAttribute("value", nValue)
- elif flagSchema:
- flagChange = False
- foundValue = nextOldNode.hasAttribute("schema")
- if foundValue:
- oSchema = nextOldNode.getAttribute("schema")
- if nSchema != oSchema:
- flagChange = True
- else:
+ else:
+ flagChange = True
+ if flagChange:
+ nextOldNode.set("mtime", self.currentTime)
+ nextOldNode.set("value", nValue)
+ elif flagSchema:
+ flagChange = False
+ if "schema" in nextOldNode.keys():
+ oSchema = nextOldNode.get("schema")
+ if nSchema != oSchema:
flagChange = True
- if flagChange:
- nextOldNode.setAttribute("mtime",
- self.currentTime)
- nextOldNode.setAttribute("schema", nSchema)
- # Замещение ноды
- elif flagReplace:
- replaceXmlNode = xmlNode.cloneNode(True)
- # Сравнение содержимого нод
- if not self.cmpListsNodesEntry([replaceXmlNode],
- [nextOldNode]):
- replaceXmlNode.setAttribute("mtime",
- self.currentTime)
- if not self._removeDropNodesAndAttrAction(
- replaceXmlNode):
- return False
- workNode.replaceChild(replaceXmlNode,
- nextOldNode)
- childNodes = False
- # Удаление ноды
- elif flagDrop:
- workNode.removeChild(nextOldNode)
- childNodes = False
- else:
- # Добавление ноды
- childNodes = False
- if not flagDrop:
- appendXmlNode = xmlNode.cloneNode(True)
- appendXmlNode.setAttribute("mtime", self.currentTime)
+ else:
+ flagChange = True
+ if flagChange:
+ nextOldNode.set("mtime", self.currentTime)
+ nextOldNode.set("schema", nSchema)
+ # Замещение ноды
+ elif flagReplace:
+ replaceXmlNode = deepcopy(xmlNode)
+ # Сравнение содержимого нод
+ if not self.cmpListsNodesEntry([replaceXmlNode],
+ [nextOldNode]):
+ replaceXmlNode.set("mtime",
+ self.currentTime)
if not self._removeDropNodesAndAttrAction(
- appendXmlNode):
+ replaceXmlNode):
return False
- workNode.appendChild(appendXmlNode)
- if isinstance(childNodes, Iterable):
- for node in childNodes:
- levelNumber += 1
- if not self._join(node, nextOldNode, False, levelNumber):
+ workNode.replace(nextOldNode, replaceXmlNode)
+ childNodes = False
+ # Удаление ноды
+ elif flagDrop:
+ workNode.remove(nextOldNode)
+ childNodes = False
+ else:
+ # Добавление ноды
+ childNodes = False
+ if not flagDrop:
+ appendXmlNode = deepcopy(xmlNode)
+ appendXmlNode.set("mtime", self.currentTime)
+ if not self._removeDropNodesAndAttrAction(
+ appendXmlNode):
return False
- levelNumber -= 1
+ workNode.append(appendXmlNode)
+ if isinstance(childNodes, Iterable):
+ for node in childNodes:
+ levelNumber += 1
+ if not self._join(node, nextOldNode, False, levelNumber):
+ return False
+ levelNumber -= 1
return True
def join(self, xml_gconfObj):
@@ -283,7 +282,7 @@ class xml_gconf(xml_xfce):
else:
return s
- data = self.doc.toprettyxml().split("\n")
+ data = self.doc.toxml().split("\n")
data = map(lambda x: expandStartTabs(x),
filter(lambda x: x.strip(), data))
dataOut = []
diff --git a/pym/calculate/lib/format/xml_gconf_tree.py b/pym/calculate/lib/format/xml_gconf_tree.py
index 4353882..a4ffecc 100644
--- a/pym/calculate/lib/format/xml_gconf_tree.py
+++ b/pym/calculate/lib/format/xml_gconf_tree.py
@@ -19,6 +19,7 @@ from calculate.lib.cl_xml import xpath
from calculate.lib.format.xml_gconf import xml_gconf
from calculate.lib.cl_lang import setLocalTranslate
from collections import Iterable
+from copy import deepcopy
_ = lambda x: x
setLocalTranslate('cl_lib3', sys.modules[__name__])
@@ -30,11 +31,11 @@ class xml_gconf_tree(xml_gconf):
def _join(self, xmlNewNode, xmlOldNode, flagRootNode=True, **kw):
"""Объединение корневой ноды шаблона и корневой ноды файла"""
xmlNode = xmlNewNode
- childNodes = xmlNode.childNodes
+ childNodes = xmlNode.getchildren()
nextOldNode = xmlOldNode
if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
n = xmlNode
- tagName = n.tagName
+ tagName = n.tag
tagNameStr = tagName.encode("UTF-8")
nAction = u''
attrName = ''
@@ -48,15 +49,15 @@ class xml_gconf_tree(xml_gconf):
self.setError(_("The text is not a valid gconf-XML format \
(found '<%(tag)s>..%(tag)s>')") % {'tag': tagNameStr})
return False
- if not n.hasAttribute("name"):
+ if "name" not in n.keys():
self.setError(
_('Not found attribute "name" in %(tag)s')
% {'tag': tagNameStr})
return False
- nName = n.getAttribute("name")
+ nName = n.get("name")
attrName = u"attribute::name='%s'" % nName
- if n.hasAttribute("action"):
- nAction = n.getAttribute("action")
+ if "action" in n.keys():
+ nAction = n.get("action")
if nAction not in ("join", "replace", "drop"):
textError = _("In the text of the XML template, "
"reserved attribute 'action' comes with an "
@@ -66,14 +67,14 @@ class xml_gconf_tree(xml_gconf):
'action="drop")')
self.setError(textError)
return False
- if xmlOldNode.parentNode:
+ if xmlOldNode.getparent() is not None:
findAttrStr = ""
if attrName:
findAttrStr = "[%s]" % attrName
findPath = u"child::%s%s" % (tagName, findAttrStr)
# Рабочая нода
if flagRootNode:
- workNode = xmlOldNode.parentNode
+ workNode = xmlOldNode.getparent()
else:
workNode = xmlOldNode
oldNodes = xpath.Evaluate(findPath, workNode)
@@ -102,25 +103,23 @@ class xml_gconf_tree(xml_gconf):
nextOldNode = oldNodes[0]
# Объединение аттрибутов нод
if flagJoin:
- listOldAttributes = nextOldNode.attributes.items()
+ listOldAttributes = nextOldNode.attrib.items()
if listOldAttributes:
listOldAttributes = filter(
lambda x: x[0] != "mtime", listOldAttributes)
# Замена содержимого
- if xmlNode.tagName == "entry":
- replaceXmlNode = xmlNode.cloneNode(True)
+ if xmlNode.tag == "entry":
+ replaceXmlNode = deepcopy(xmlNode)
# Сравнение содержимого нод
if not self.cmpListsNodesEntry([replaceXmlNode],
[nextOldNode]):
- replaceXmlNode.setAttribute("mtime",
- self.currentTime)
+ replaceXmlNode.set("mtime", self.currentTime)
if not self._removeDropNodesAndAttrAction(
replaceXmlNode):
return False
- workNode.replaceChild(replaceXmlNode,
- nextOldNode)
+ workNode.replace(nextOldNode, replaceXmlNode)
childNodes = False
- listNewAttributes = xmlNode.attributes.items()
+ listNewAttributes = xmlNode.attrib.items()
if listNewAttributes:
listNewAttributes = filter(
lambda x: x[0] not in ("action", "mtime"),
@@ -128,41 +127,40 @@ class xml_gconf_tree(xml_gconf):
if set(listNewAttributes) != set(listOldAttributes):
# Объединение аттрибутов
for attrName, attrValue in listNewAttributes:
- nextOldNode.setAttribute(attrName, attrValue)
- if nextOldNode.tagName == "entry":
- nextOldNode.setAttribute("mtime",
+ nextOldNode.set(attrName, attrValue)
+ if nextOldNode.tag == "entry":
+ nextOldNode.set("mtime",
self.currentTime)
# Замещение ноды
elif flagReplace:
- replaceXmlNode = xmlNode.cloneNode(True)
+ replaceXmlNode = deepcopy(xmlNode)
# Сравнение содержимого нод
if not self.cmpListsNodesEntry([replaceXmlNode],
[nextOldNode]):
- if replaceXmlNode.tagName == "entry":
- replaceXmlNode.setAttribute("mtime",
+ if replaceXmlNode.tag == "entry":
+ replaceXmlNode.set("mtime",
self.currentTime)
if not self._removeDropNodesAndAttrAction(
replaceXmlNode):
return False
- workNode.replaceChild(replaceXmlNode,
- nextOldNode)
+ workNode.replace(nextOldNode, replaceXmlNode)
childNodes = False
# Удаление ноды
elif flagDrop:
- workNode.removeChild(nextOldNode)
+ workNode.remove(nextOldNode)
childNodes = False
else:
# Добавление ноды
childNodes = False
if not flagDrop:
- appendXmlNode = xmlNode.cloneNode(True)
- if appendXmlNode.tagName == "entry":
- appendXmlNode.setAttribute("mtime",
+ appendXmlNode = deepcopy(xmlNode)
+ if appendXmlNode.tag == "entry":
+ appendXmlNode.set("mtime",
self.currentTime)
if not self._removeDropNodesAndAttrAction(
appendXmlNode):
return False
- workNode.appendChild(appendXmlNode)
+ workNode.append(appendXmlNode)
if isinstance(childNodes, Iterable):
for node in childNodes:
if not self._join(node, nextOldNode, False):
diff --git a/pym/calculate/lib/format/xml_xfce.py b/pym/calculate/lib/format/xml_xfce.py
index faedea6..9138417 100644
--- a/pym/calculate/lib/format/xml_xfce.py
+++ b/pym/calculate/lib/format/xml_xfce.py
@@ -16,11 +16,12 @@
import sys
from calculate.lib.cl_xml import xpath
-import xml.dom.minidom
+# import xml.dom.minidom
+from lxml import etree
from calculate.lib.cl_template import TemplateFormat
from calculate.lib.cl_lang import setLocalTranslate
from collections import Iterable
-
+from copy import deepcopy
_ = lambda x: x
setLocalTranslate('cl_lib3', sys.modules[__name__])
@@ -58,7 +59,7 @@ class xml_xfce(TemplateFormat):
"""Устанавливает название для корневой ноды документа"""
if not self.bodyNode:
return False
- self.bodyNode.setAttribute("name", name)
+ self.bodyNode.set("name", name)
return True
def textToXML(self):
@@ -70,11 +71,12 @@ class xml_xfce(TemplateFormat):
'''
try:
- self.doc = xml.dom.minidom.parseString(self.text)
+ # self.doc = xml.dom.minidom.parseString(self.text)
+ self.doc = etree.XML(bytes(bytearray(self.text, encoding='utf-8')))
except Exception:
self.setError(_("The template content is not XML"))
return False
- self.rootNode = self.doc.documentElement
+ self.rootNode = self.doc
self.bodyNode = self.rootNode
return self.doc
@@ -93,28 +95,28 @@ class xml_xfce(TemplateFormat):
Также удаляет аттрибут action у всех нод
"""
- childNodes = xmlNode.childNodes
- if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
- if xmlNode.hasAttribute("action"):
- nAction = xmlNode.getAttribute("action")
- if nAction not in ("join", "replace", "drop"):
- textError = _("In the text of the XML template, "
- "reserved attribute 'action' comes with an "
- "incorrect value.\n"
- "Valid values of the 'action' attribute are: "
- '(action="join", action="replace",'
- 'action="drop")')
- self.setError(textError)
+ childNodes = xmlNode.getchildren()
+ # if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
+ if "action" in xmlNode.keys():
+ nAction = xmlNode.get("action")
+ if nAction not in ("join", "replace", "drop"):
+ textError = _("In the text of the XML template, "
+ "reserved attribute 'action' comes with an "
+ "incorrect value.\n"
+ "Valid values of the 'action' attribute are: "
+ '(action="join", action="replace",'
+ 'action="drop")')
+ self.setError(textError)
+ return False
+ xmlNode.removeAttribute("action")
+ if nAction == "drop":
+ parentNode = xmlNode.getparent()
+ if parentNode:
+ parentNode.remove(xmlNode)
+ if childNodes:
+ for node in childNodes:
+ if not self._removeDropNodesAndAttrAction(node):
return False
- xmlNode.removeAttribute("action")
- if nAction == "drop":
- parentNode = xmlNode.parentNode
- if parentNode:
- parentNode.removeChild(xmlNode)
- if childNodes:
- for node in childNodes:
- if not self._removeDropNodesAndAttrAction(node):
- return False
return True
def postXML(self):
@@ -125,114 +127,112 @@ class xml_xfce(TemplateFormat):
def _join(self, xmlNewNode, xmlOldNode, flagRootNode=True):
"""Объединение корневой ноды шаблона и корневой ноды файла"""
xmlNode = xmlNewNode
- childNodes = xmlNode.childNodes
+ childNodes = xmlNode.getchildren()
nextOldNode = xmlOldNode
- if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
- n = xmlNode
- nType = u''
- nValue = u''
- nAction = u''
- attrName = ''
- attrType = ''
- path = n.tagName
- if n.hasAttribute("name"):
- nName = n.getAttribute("name")
- attrName = u"attribute::name='%s'" % nName
- if n.hasAttribute("type"):
- nType = n.getAttribute("type")
- attrType = u"attribute::type='%s'" % nType
- if n.hasAttribute("value"):
- nValue = n.getAttribute("value")
- if n.hasAttribute("action"):
- nAction = n.getAttribute("action")
- if not nAction in ("join", "replace", "drop"):
- textError = _(
- "In the text of the XML template, "
- "reserved attribute 'action' comes with an "
- "incorrect value.\n"
- "Valid values of the 'action' attribute are: "
- '(action="join", action="replace", action="drop")')
+ # if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
+ n = xmlNode
+ nType = u''
+ nValue = u''
+ nAction = u''
+ attrName = ''
+ attrType = ''
+ path = n.tag
+ if "name" in n.keys():
+ nName = n.get("name")
+ attrName = u"attribute::name='%s'" % nName
+ if "type" in n.keys():
+ nType = n.get("type")
+ attrType = u"attribute::type='%s'" % nType
+ if "value" in n.keys():
+ nValue = n.get("value")
+ if "action" in n.keys():
+ nAction = n.get("action")
+ if not nAction in ("join", "replace", "drop"):
+ textError = _(
+ "In the text of the XML template, "
+ "reserved attribute 'action' comes with an "
+ "incorrect value.\n"
+ "Valid values of the 'action' attribute are: "
+ '(action="join", action="replace", action="drop")')
+ self.setError(textError)
+ return False
+ if xmlOldNode.getparent():
+ strAttr = [attrName, attrType]
+ findAttr = filter(lambda x: x, strAttr)
+ findAttrStr = ''
+ if findAttr:
+ strAttr = u' and '.join(findAttr)
+ findAttrStr = "[%s]" % strAttr
+ findPath = u"child::%s%s" % (path, findAttrStr)
+ # Рабочая нода
+ if flagRootNode:
+ workNode = xmlOldNode.getparent()
+ else:
+ workNode = xmlOldNode
+ oldNodes = xpath.Evaluate(findPath, workNode)
+ # Новая нода список
+ flagArray = nType == "array"
+ flagDrop = False
+ flagJoin = True
+ flagReplace = False
+ if nAction == "replace":
+ flagJoin = False
+ flagReplace = True
+ elif nAction == "drop":
+ flagJoin = False
+ flagDrop = True
+ if flagRootNode:
+ textError = _('Incorrect action="drop" in '
+ 'the root node')
self.setError(textError)
return False
- if xmlOldNode.parentNode:
- strAttr = [attrName, attrType]
- findAttr = filter(lambda x: x, strAttr)
- findAttrStr = ''
- if findAttr:
- strAttr = u' and '.join(findAttr)
- findAttrStr = "[%s]" % strAttr
- findPath = u"child::%s%s" % (path, findAttrStr)
- # Рабочая нода
- if flagRootNode:
- workNode = xmlOldNode.parentNode
- else:
- workNode = xmlOldNode
- oldNodes = xpath.Evaluate(findPath, workNode)
- # Новая нода список
- flagArray = nType == "array"
- flagDrop = False
- flagJoin = True
- flagReplace = False
- if nAction == "replace":
- flagJoin = False
- flagReplace = True
- elif nAction == "drop":
+ if oldNodes:
+ if len(oldNodes) > 1:
+ textError = _("Ambiguity in this template: "
+ "the same nodes are on a same level")
+ self.setError(textError)
+ return False
+ nextOldNode = oldNodes[0]
+ # Замещаем ноду в случае массива
+ if flagArray and not flagDrop:
+ replaceXmlNode = deepcopy(xmlNode)
+ if nAction:
+ del replaceXmlNode.attrib["action"]
+ workNode.replace(nextOldNode, replaceXmlNode)
flagJoin = False
- flagDrop = True
- if flagRootNode:
- textError = _('Incorrect action="drop" in '
- 'the root node')
- self.setError(textError)
- return False
- if oldNodes:
- if len(oldNodes) > 1:
- textError = _("Ambiguity in this template: "
- "the same nodes are on a same level")
- self.setError(textError)
+ flagReplace = False
+ childNodes = False
+ # Объединение нод
+ if flagJoin:
+ if "value" in nextOldNode.keys():
+ oValue = nextOldNode.getAttribute("value")
+ if nValue != oValue:
+ nextOldNode.setAttribute("value", nValue)
+ # Замещение ноды
+ elif flagReplace:
+ replaceXmlNode = deepcopy(xmlNode)
+ if not self._removeDropNodesAndAttrAction(
+ replaceXmlNode):
return False
- nextOldNode = oldNodes[0]
- # Замещаем ноду в случае массива
- if flagArray and not flagDrop:
- replaceXmlNode = xmlNode.cloneNode(True)
- if nAction:
- replaceXmlNode.removeAttribute("action")
- workNode.replaceChild(replaceXmlNode,
- nextOldNode)
- flagJoin = False
- flagReplace = False
- childNodes = False
- # Объединение нод
- if flagJoin:
- if nextOldNode.hasAttribute("value"):
- oValue = nextOldNode.getAttribute("value")
- if nValue != oValue:
- nextOldNode.setAttribute("value", nValue)
- # Замещение ноды
- elif flagReplace:
- replaceXmlNode = xmlNode.cloneNode(True)
- if not self._removeDropNodesAndAttrAction(
- replaceXmlNode):
- return False
- workNode.replaceChild(replaceXmlNode,
- nextOldNode)
- childNodes = False
- # Удаление ноды
- elif flagDrop:
- workNode.removeChild(nextOldNode)
- childNodes = False
- else:
- # Добавление ноды
+ workNode.replace(nextOldNode, replaceXmlNode)
+ childNodes = False
+ # Удаление ноды
+ elif flagDrop:
+ workNode.remove(nextOldNode)
childNodes = False
- if not flagDrop:
- appendXmlNode = xmlNode.cloneNode(True)
- if not self._removeDropNodesAndAttrAction(
- appendXmlNode):
- return False
- workNode.appendChild(appendXmlNode)
- if isinstance(childNodes, Iterable):
- for node in childNodes:
- if not self._join(node, nextOldNode, False):
+ else:
+ # Добавление ноды
+ childNodes = False
+ if not flagDrop:
+ appendXmlNode = deepcopy(xmlNode)
+ if not self._removeDropNodesAndAttrAction(
+ appendXmlNode):
return False
+ workNode.append(appendXmlNode)
+ if isinstance(childNodes, Iterable):
+ for node in childNodes:
+ if not self._join(node, nextOldNode, False):
+ return False
return True
def joinDoc(self, doc):
@@ -246,7 +246,7 @@ class xml_xfce(TemplateFormat):
# Импортируем корневую ноду нового документа в текущий документ
# newImportBodyNode = self.doc.importNode(doc.documentElement, True)
# Объединение корневой ноды шаблона и корневой ноды файла
- if not self._join(doc.documentElement, self.bodyNode):
+ if not self._join(doc, self.bodyNode):
return False
return True
diff --git a/pym/calculate/lib/format/xml_xfcepanel.py b/pym/calculate/lib/format/xml_xfcepanel.py
index b3fdeab..403d40b 100644
--- a/pym/calculate/lib/format/xml_xfcepanel.py
+++ b/pym/calculate/lib/format/xml_xfcepanel.py
@@ -16,10 +16,11 @@
import sys
from calculate.lib.cl_xml import xpath
-import xml.dom.minidom
+# import xml.dom.minidom
+from lxml import etree
from calculate.lib.format.xml_xfce import xml_xfce
from collections import Iterable
-
+from copy import deepcopy
from calculate.lib.cl_lang import setLocalTranslate
_ = lambda x: x
@@ -43,11 +44,12 @@ class xml_xfcepanel(xml_xfce):
'''
try:
- self.doc = xml.dom.minidom.parseString(self.text)
+ # self.doc = xml.dom.minidom.parseString(self.text)
+ self.doc = etree.XML(bytes(bytearray(self.text, encoding='utf-8')))
except Exception:
self.setError(_("The template content is not XML"))
return False
- self.rootNode = self.doc.documentElement
+ self.rootNode = self.doc.getroottree()
self.bodyNode = self.rootNode
return self.doc
@@ -58,132 +60,130 @@ class xml_xfcepanel(xml_xfce):
def _join(self, xmlNewNode, xmlOldNode, flagRootNode=True, levelNumber=0):
"""Объединение корневой ноды шаблона и корневой ноды файла"""
xmlNode = xmlNewNode
- childNodes = xmlNode.childNodes
+ childNodes = xmlNode.getchildren()
nextOldNode = xmlOldNode
- if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
- n = xmlNode
- flagArray = False
- nValue = u''
- nAction = u''
- attrName = ''
- path = n.tagName
- if path == "items":
- flagArray = True
- if not flagArray:
- if n.hasAttribute("name"):
- nName = n.getAttribute("name")
- attrName = u"attribute::name='%s'" % nName
- if n.hasAttribute("value"):
- nValue = n.getAttribute("value")
- if n.hasAttribute("action"):
- nAction = n.getAttribute("action")
- if not nAction in ("join", "replace", "drop"):
- textError = _("In the text of the XML template, "
- "reserved attribute 'action' comes with an "
- "incorrect value.\n"
- "Valid values of the 'action' attribute are: "
- '(action="join", action="replace", '
- 'action="drop")')
+ # if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
+ n = xmlNode
+ flagArray = False
+ nValue = u''
+ nAction = u''
+ attrName = ''
+ path = n.tag
+ if path == "items":
+ flagArray = True
+ if not flagArray:
+ if "name" in n.keys():
+ nName = n.get("name")
+ attrName = u"attribute::name='%s'" % nName
+ if "value" in n.keys():
+ nValue = n.get("value")
+ if "action" in n.keys():
+ nAction = n.get("action")
+ if not nAction in ("join", "replace", "drop"):
+ textError = _("In the text of the XML template, "
+ "reserved attribute 'action' comes with an "
+ "incorrect value.\n"
+ "Valid values of the 'action' attribute are: "
+ '(action="join", action="replace", '
+ 'action="drop")')
+ self.setError(textError)
+ return False
+ if xmlOldNode.getparent() is not None:
+ findAttrStr = ""
+ if attrName:
+ findAttrStr = "[%s]" % attrName
+ findPath = u"child::%s%s" % (path, findAttrStr)
+ # Рабочая нода
+ if flagRootNode:
+ workNode = xmlOldNode.getparent()
+ else:
+ workNode = xmlOldNode
+ oldNodes = xpath.Evaluate(findPath, workNode)
+ flagDrop = False
+ flagJoin = True
+ flagReplace = False
+ flagAppend = False
+ if nAction == "replace":
+ flagJoin = False
+ flagReplace = True
+ elif nAction == "drop":
+ flagJoin = False
+ flagDrop = True
+ if flagRootNode:
+ textError = _('Incorrect action="drop" '
+ 'in the root node')
self.setError(textError)
return False
- if xmlOldNode.parentNode:
- findAttrStr = ""
- if attrName:
- findAttrStr = "[%s]" % attrName
- findPath = u"child::%s%s" % (path, findAttrStr)
- # Рабочая нода
- if flagRootNode:
- workNode = xmlOldNode.parentNode
+ if path == "panel":
+ flagJoin = False
+ if levelNumber in self.panelNumbers.keys():
+ self.panelNumbers[levelNumber] += 1
else:
- workNode = xmlOldNode
- oldNodes = xpath.Evaluate(findPath, workNode)
- flagDrop = False
- flagJoin = True
- flagReplace = False
- flagAppend = False
- if nAction == "replace":
- flagJoin = False
- flagReplace = True
- elif nAction == "drop":
- flagJoin = False
- flagDrop = True
- if flagRootNode:
- textError = _('Incorrect action="drop" '
- 'in the root node')
- self.setError(textError)
- return False
+ self.panelNumbers[levelNumber] = 0
+ if oldNodes:
+ if len(oldNodes) > 1 and path != "panel":
+ textError = _("Ambiguity in this template: the "
+ "same nodes are on a same level")
+ self.setError(textError)
+ return False
if path == "panel":
- flagJoin = False
- if levelNumber in self.panelNumbers.keys():
- self.panelNumbers[levelNumber] += 1
- else:
- self.panelNumbers[levelNumber] = 0
- if oldNodes:
- if len(oldNodes) > 1 and path != "panel":
- textError = _("Ambiguity in this template: the "
- "same nodes are on a same level")
- self.setError(textError)
- return False
- if path == "panel":
- if len(oldNodes) <= self.panelNumbers[levelNumber]:
- nextOldNode = oldNodes[-1]
- # Добавляем ноду
- if not flagDrop:
- flagAppend = True
- flagReplace = False
- childNodes = False
- else:
- nextOldNode = oldNodes[
- self.panelNumbers[levelNumber]]
+ if len(oldNodes) <= self.panelNumbers[levelNumber]:
+ nextOldNode = oldNodes[-1]
+ # Добавляем ноду
+ if not flagDrop:
+ flagAppend = True
+ flagReplace = False
+ childNodes = False
else:
- nextOldNode = oldNodes[0]
- # Замещаем ноду в случае массива
- if flagArray and not flagDrop:
- replaceXmlNode = xmlNode.cloneNode(True)
- if nAction:
- replaceXmlNode.removeAttribute("action")
- workNode.replaceChild(replaceXmlNode,
- nextOldNode)
- flagJoin = False
- flagReplace = False
- childNodes = False
- # Объединение нод
- if flagJoin:
- if nextOldNode.hasAttribute("value"):
- oValue = nextOldNode.getAttribute("value")
- if nValue != oValue:
- nextOldNode.setAttribute("value", nValue)
- # Замещение ноды
- elif flagReplace:
- replaceXmlNode = xmlNode.cloneNode(True)
- if not self._removeDropNodesAndAttrAction(
- replaceXmlNode):
- return False
- workNode.replaceChild(replaceXmlNode,
- nextOldNode)
- childNodes = False
- # Удаление ноды
- elif flagDrop:
- workNode.removeChild(nextOldNode)
- childNodes = False
+ nextOldNode = oldNodes[
+ self.panelNumbers[levelNumber]]
else:
- flagAppend = True
- flagDrop = False
- if flagAppend and not flagDrop:
- # Добавление ноды
+ nextOldNode = oldNodes[0]
+ # Замещаем ноду в случае массива
+ if flagArray and not flagDrop:
+ replaceXmlNode = deepcopy(xmlNode)
+ if nAction:
+ del replaceXmlNode.attrib["action"]
+ workNode.replace(nextOldNode, replaceXmlNode)
+ flagJoin = False
+ flagReplace = False
childNodes = False
- if not flagDrop:
- appendXmlNode = xmlNode.cloneNode(True)
- if not self._removeDropNodesAndAttrAction(
- appendXmlNode):
- return False
- workNode.appendChild(appendXmlNode)
- if isinstance(childNodes, Iterable):
- for node in childNodes:
- levelNumber += 1
- if not self._join(node, nextOldNode, False, levelNumber):
+ # Объединение нод
+ if flagJoin:
+ if "value" in nextOldNode.keys():
+ oValue = nextOldNode.get("value")
+ if nValue != oValue:
+ nextOldNode.set("value", nValue)
+ # Замещение ноды
+ elif flagReplace:
+ replaceXmlNode = deepcopy(xmlNode)
+ if not self._removeDropNodesAndAttrAction(
+ replaceXmlNode):
return False
- levelNumber -= 1
+ workNode.replace(nextOldNode, replaceXmlNode)
+ childNodes = False
+ # Удаление ноды
+ elif flagDrop:
+ workNode.remove(nextOldNode)
+ childNodes = False
+ else:
+ flagAppend = True
+ flagDrop = False
+ if flagAppend and not flagDrop:
+ # Добавление ноды
+ childNodes = False
+ if not flagDrop:
+ appendXmlNode = deepcopy(xmlNode)
+ if not self._removeDropNodesAndAttrAction(
+ appendXmlNode):
+ return False
+ workNode.append(appendXmlNode)
+ if isinstance(childNodes, Iterable):
+ for node in childNodes:
+ levelNumber += 1
+ if not self._join(node, nextOldNode, False, levelNumber):
+ return False
+ levelNumber -= 1
return True
def join(self, xml_xfceObj):