Commit e15bb26d authored by Pavel Vainerman's avatar Pavel Vainerman

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

(python): подправил коментарии к некоторым функциям и изменил название на более "удачное". Добавил в UniXML параметр позволяющий загружать xml не только из файла, но и из "памяти"(строки).
parent 446ee2f2
...@@ -34,9 +34,13 @@ class UniXMLException(Exception): ...@@ -34,9 +34,13 @@ class UniXMLException(Exception):
# ----------------------------- # -----------------------------
class UniXML(): class UniXML():
def __init__(self, xfile): def __init__(self, xfile, isDoc=False):
try: try:
self.doc = None self.doc = None
if isDoc:
self.fname = ''
self.doc = libxml2.parseDoc(xfile)
else:
self.fname = xfile self.fname = xfile
self.doc = libxml2.parseFile(xfile) self.doc = libxml2.parseFile(xfile)
except libxml2.parserError: except libxml2.parserError:
...@@ -147,9 +151,13 @@ class UniXML(): ...@@ -147,9 +151,13 @@ class UniXML():
return self.doc.saveFile(filename) return self.doc.saveFile(filename)
def reopen(self, filename): def reopen(self, filename, isDoc=False):
try: try:
self.doc.freeDoc() self.doc.freeDoc()
if isDoc:
self.fname = ''
self.doc = libxml2.parseDoc(filename)
else:
self.fname = filename self.fname = filename
self.doc = libxml2.parseFile(filename) self.doc = libxml2.parseFile(filename)
except libxml2.parserError: except libxml2.parserError:
......
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