backend/satellite_tools/xmlSource.py | 14 ++++----------
backend/server/importlib/backendLib.py | 6 ++----
2 files changed, 6 insertions(+), 14 deletions(-)
New commits:
commit 26dd1e30e7f49b56ca14f78420c44333e87f2d68
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 4 18:38:41 2009 +0100
save some time
this function is called many time, not allocating another variable will save us some
time
diff --git a/backend/server/importlib/backendLib.py
b/backend/server/importlib/backendLib.py
index caf0918..7be742e 100644
--- a/backend/server/importlib/backendLib.py
+++ b/backend/server/importlib/backendLib.py
@@ -25,12 +25,10 @@ from types import ListType, StringType, DictType, IntType
# A function that formats a UNIX timestamp to the session's format
def gmtime(timestamp):
- ttuple = time.gmtime(float(timestamp))
- return _format_time(ttuple)
+ return _format_time(time.gmtime(float(timestamp)))
def localtime(timestamp):
- ttuple = time.localtime(float(timestamp))
- return _format_time(ttuple)
+ return _format_time(time.localtime(float(timestamp)))
def _format_time(time_tuple):
return "%d-%02d-%02d %02d:%02d:%02d" % time_tuple[:6]
commit 272bf4b9fd886b81b74c43d9c5aa46bf7659a145
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 4 18:26:55 2009 +0100
replace isinstance with has_key
isinstance is evil and slow, it cost us 6 seconds per channel
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index bc45a31..2af35ff 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -821,7 +821,7 @@ class ContainerHandler:
# Nothing to do with this object
return
- if isinstance(item, importLib.Error):
+ if item.has_key('error'):
# Special case errors
log_debug(0, 'XML parser error: found "rhn-error" item: %s'
%
item['error'])
commit 26e93d9737bba56caa4b663e10fb86b6dbe2944f
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 4 18:09:25 2009 +0100
do not check xml corectness twice
We already check if opening and closing tag match in class ContainerHandler.
And there we use tagStack for something else too, therefore deleting from this class.
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index bc52a56..bc45a31 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -110,8 +110,6 @@ class BaseDispatchHandler(ContentHandler, ErrorHandler):
self.restoreParser()
# No container at this time
self.__container = None
- # Simple tag stack, to ensure corectness
- self.tagStack = []
# Reset all the containers, to make sure previous runs don't leave
# garbage data
for container in self.container_dispatch.values():
@@ -191,7 +189,6 @@ class BaseDispatchHandler(ContentHandler, ErrorHandler):
def startElement(self, element, attrs):
log_debug(6, element)
- self.tagStack.append(element)
utf8_attrs = _dict_to_utf8(attrs)
if self.rootAttributes is None:
# First time around
@@ -214,10 +211,6 @@ class BaseDispatchHandler(ContentHandler, ErrorHandler):
def endElement(self, element):
log_debug(6, element)
- top = self.tagStack[-1]
- del self.tagStack[-1]
- if element != top:
- raise Exception("TTT")
if self.__container is None:
# End of the root attribute
# We know now the tag stack is empty
commit 1f21422260e314d1f06452cf8345974adb912b4b
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 4 18:16:55 2009 +0100
call _dict_to_utf8 only once
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index 8e17d8b..bc52a56 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -192,12 +192,13 @@ class BaseDispatchHandler(ContentHandler, ErrorHandler):
def startElement(self, element, attrs):
log_debug(6, element)
self.tagStack.append(element)
+ utf8_attrs = _dict_to_utf8(attrs)
if self.rootAttributes is None:
# First time around
if self.rootElement != element:
raise Exception("Mismatching elements; root='%s', "
"received='%s'" % (self.rootElement, element))
- self.rootAttributes = _dict_to_utf8(attrs)
+ self.rootAttributes = utf8_attrs
self._check_version()
return
@@ -205,7 +206,7 @@ class BaseDispatchHandler(ContentHandler, ErrorHandler):
# This means it's parsing a container element
self.__container = self.get_container(element)
- self.__container.startElement(element, _dict_to_utf8(attrs))
+ self.__container.startElement(element, utf8_attrs)
def characters(self, data):
if self.__container:
Show replies by date