backend/satellite_tools/satsync.py | 2 +-
backend/satellite_tools/xmlDiskDumper.py | 2 +-
backend/satellite_tools/xmlSource.py | 28 +++++++++++-----------------
3 files changed, 13 insertions(+), 19 deletions(-)
New commits:
commit e8eab333afa277988a4a23635a3de5ac9441f742
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 14 14:28:44 2010 +0200
don't (re)link all packages just missing ones
diff --git a/backend/satellite_tools/satsync.py b/backend/satellite_tools/satsync.py
index 17eea89..8c8adef 100644
--- a/backend/satellite_tools/satsync.py
+++ b/backend/satellite_tools/satsync.py
@@ -1728,7 +1728,7 @@ Please contact your RHN representative""" %
(generation, sat_cert.generation))
log(1, ["", messages.link_channel_packages])
package_collection = sync_handlers.PackageCollection()
uq_packages = {}
- for chn, package_ids in self._channel_packages.items():
+ for chn, package_ids in self._missing_channel_packages.items():
for pid in package_ids:
timestamp = package_collection.get_package_timestamp(pid)
package = package_collection.get_package(pid, timestamp)
commit cb2cf2fe6c0edf64f7e7e570bf4aa48e35802d0d
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 14 11:44:35 2010 +0200
removed obsoleted code: at least since RHEL4 we always have unicode
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index ef2d30f..7901f13 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -26,8 +26,6 @@ from common import log_debug, Traceback, rhnFlags, CFG
from server.importlib import importLib, backendLib
-typesHasUnicode = hasattr(types, "UnicodeType")
-
# Terminology used throughout this file:
# Item: an atomic entity from the database's perspective.
# A channel, or a package, or an erratum is an item.
@@ -336,7 +334,7 @@ class BaseItem:
def _is_string(obj):
if isinstance(obj, types.StringType):
return 1
- if typesHasUnicode and isinstance(obj, types.UnicodeType):
+ if isinstance(obj, types.UnicodeType):
return 1
return 0
@@ -344,16 +342,12 @@ def _stringify(data):
# Accelerate the most common cases
if isinstance(data, types.StringType):
return data
- if typesHasUnicode:
- try: return data.encode('UTF8')
- except AttributeError: pass
+ try: return data.encode('UTF8')
+ except AttributeError: pass
return str(data)
def _dict_to_utf8(d):
# Convert the dictionary to have non-unocide key-value pairs
- if not typesHasUnicode:
- # Nothing to do
- return d
ret = {}
for k, v in d.items():
try: k = k.encode('UTF8')
commit 76c5af81470ae743f990d78cd722fc65d43bdfaa
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 14 11:34:14 2010 +0200
xml import optimization: 'key in dict' is 15% faster than
'dict.has_key(key)' and it's called 1000000 times during satellite-sync
diff --git a/backend/satellite_tools/xmlDiskDumper.py
b/backend/satellite_tools/xmlDiskDumper.py
index c4d326b..2e9f323 100644
--- a/backend/satellite_tools/xmlDiskDumper.py
+++ b/backend/satellite_tools/xmlDiskDumper.py
@@ -257,7 +257,7 @@ class ShortPackageDumper(Dumper):
if self.compression:
filename = filename + '.gz'
- if diskfiles.has_key(filename):
+ if filename in diskfiles:
# The file is on the disk
del diskfiles[filename]
else:
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index a82d9cb..ef2d30f 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -168,7 +168,7 @@ class BaseDispatchHandler(ContentHandler, ErrorHandler):
self.container_dispatch[obj.container_name] = obj
def get_container(self, name):
- if not self.container_dispatch.has_key(name):
+ if name not in self.container_dispatch:
# Return a dummy container
c = ContainerHandler()
c.container_name = name
@@ -177,7 +177,7 @@ class BaseDispatchHandler(ContentHandler, ErrorHandler):
return self.container_dispatch[name]
def has_container(self, name):
- return self.container_dispatch.has_key(name)
+ return (name in self.container_dispatch)
# Overwrite the functions required by SAX
def setDocumentLocator(self, locator):
@@ -295,8 +295,8 @@ class BaseItem:
def populateFromAttributes(self, obj, sourceDict):
# Populates dict with items from sourceDict
for key, value in sourceDict.items():
- if not self.tagMap.has_key(key):
- if not obj.has_key(key):
+ if key not in self.tagMap:
+ if key not in obj:
# Unsupported key
continue
else:
@@ -322,10 +322,10 @@ class BaseItem:
obj[keys[0]] = element
continue
name = element.name
- if not obj.has_key(name) and not self.tagMap.has_key(name):
+ if name not in obj and name not in self.tagMap:
# Unsupported key
continue
- if self.tagMap.has_key(name):
+ if name in self.tagMap:
# Have to map this element
name = self.tagMap[name]
@@ -371,7 +371,7 @@ def addItem(classobj):
def _createItem(element):
# Creates an Item object from the specified element
- if not __itemDispatcher.has_key(element.name):
+ if element.name not in __itemDispatcher:
# No item processor
return None
item = __itemDispatcher[element.name]()
@@ -858,7 +858,7 @@ class ContainerHandler:
# Nothing to do with this object
return
- if item.has_key('error'):
+ if 'error' in item:
# Special case errors
log_debug(0, 'XML parser error: found "rhn-error" item: %s'
%
item['error'])