mirror of
https://port.numenaute.org/aleajactaest/clientbot.git
synced 2024-12-21 00:48:46 +00:00
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
|
#!/usr/bin/python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
#
|
||
|
# module CodeMsgXml
|
||
|
#
|
||
|
# Copyright (C) 2019 AleaJactaEst
|
||
|
#
|
||
|
# This program is free software: you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation, either version 3 of the License, or
|
||
|
# (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
|
||
|
import logging
|
||
|
from tools import getPowerOf2
|
||
|
|
||
|
LOGGER='CodeMsgXml'
|
||
|
|
||
|
def CodeMsgXml(msgXml, key):
|
||
|
head = msgXml
|
||
|
listpath = key.split(':')
|
||
|
ret = []
|
||
|
for id in listpath:
|
||
|
nbBit = getPowerOf2.getPowerOf2(len(head))
|
||
|
found = False
|
||
|
i = 0
|
||
|
for ele in head:
|
||
|
if ele.attrib['name'] == id:
|
||
|
found = True
|
||
|
ret.append([nbBit, i, id])
|
||
|
break
|
||
|
i +=1
|
||
|
if not found:
|
||
|
logging.getLogger(LOGGER).error("Impossible to found value (all key:%s, value:%s)" % (key, id))
|
||
|
raise ValueError
|
||
|
head = ele
|
||
|
return ret
|