Commit e15bb26d authored by Pavel Vainerman's avatar Pavel Vainerman

(python): подправил коментарии к некоторым функциям и изменил название на более…

(python): подправил коментарии к некоторым функциям и изменил название на более "удачное". Добавил в UniXML параметр позволяющий загружать xml не только из файла, но и из "памяти"(строки).
parent 446ee2f2
......@@ -94,7 +94,7 @@ def to_sid(str_id, ui):
# Получение списка пар [id@node,int(val)] из строки "id1@node1=val1,id2=val2,.."
def get_int_list(raw_str,sep='='):
if raw_str == None or raw_str == "":
return []
......
......@@ -33,12 +33,16 @@ class UniXMLException(Exception):
return self.err
# -----------------------------
class UniXML():
def __init__(self, xfile):
def __init__(self, xfile, isDoc=False):
try:
self.doc = None
self.fname = xfile
self.doc = libxml2.parseFile(xfile)
if isDoc:
self.fname = ''
self.doc = libxml2.parseDoc(xfile)
else:
self.fname = xfile
self.doc = libxml2.parseFile(xfile)
except libxml2.parserError:
raise UniXMLException("(UniXML): Can`t open file " + xfile)
......@@ -147,11 +151,15 @@ class UniXML():
return self.doc.saveFile(filename)
def reopen(self, filename):
def reopen(self, filename, isDoc=False):
try:
self.doc.freeDoc()
self.fname = filename
self.doc = libxml2.parseFile(filename)
if isDoc:
self.fname = ''
self.doc = libxml2.parseDoc(filename)
else:
self.fname = filename
self.doc = libxml2.parseFile(filename)
except libxml2.parserError:
sys.exit(-1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment