stripped some trailing spaces

This commit is contained in:
Miroslav Stampar 2010-09-16 13:19:13 +00:00
parent 8cf1aa6abe
commit 540a9b391f

View File

@ -111,7 +111,7 @@ class XMLDump:
elements = self.__root.getElementsByTagName(elemName) elements = self.__root.getElementsByTagName(elemName)
if elements : if elements :
return elements[0] return elements[0]
return elements return elements
def __createTextNode(self,data): def __createTextNode(self,data):
@ -151,8 +151,8 @@ class XMLDump:
if isinstance(data, (list, tuple, set)): if isinstance(data, (list, tuple, set)):
self.lister(header, data, sort) self.lister(header, data, sort)
return return
messagesElem = self.__getRootChild(MESSAGES_ELEM_NAME) messagesElem = self.__getRootChild(MESSAGES_ELEM_NAME)
if (not(messagesElem)): if (not(messagesElem)):
messagesElem = self.__doc.createElement(MESSAGES_ELEM_NAME) messagesElem = self.__doc.createElement(MESSAGES_ELEM_NAME)
self.__addToRoot(messagesElem) self.__addToRoot(messagesElem)
@ -161,7 +161,7 @@ class XMLDump:
data = self.__formatString(data) data = self.__formatString(data)
else : else :
data = "" data = ""
elem = self.__doc.createElement(MESSAGE_ELEM) elem = self.__doc.createElement(MESSAGE_ELEM)
elem.setAttributeNode(self.__createAttribute(TYPE_ATTR, header)) elem.setAttributeNode(self.__createAttribute(TYPE_ATTR, header))
elem.appendChild(self.__createTextNode(data)) elem.appendChild(self.__createTextNode(data))
@ -182,7 +182,7 @@ class XMLDump:
elements.sort(key=lambda x: x.lower()) elements.sort(key=lambda x: x.lower())
except: except:
pass pass
for element in elements: for element in elements:
memberElem = self.__doc.createElement(MEMBER_ELEM) memberElem = self.__doc.createElement(MEMBER_ELEM)
lstElem.appendChild(memberElem) lstElem.appendChild(memberElem)
@ -302,10 +302,10 @@ class XMLDump:
userElem = self.__doc.createElement(USER_ELEM_NAME) userElem = self.__doc.createElement(USER_ELEM_NAME)
userSettingElem.appendChild(userElem) userSettingElem.appendChild(userElem)
if user in self.__areAdmins: if user in self.__areAdmins:
userElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, ADMIN_USER)) userElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, ADMIN_USER))
else: else:
userElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, REGULAR_USER)) userElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, REGULAR_USER))
settings = userSettings[user] settings = userSettings[user]
settings.sort() settings.sort()
@ -325,7 +325,7 @@ class XMLDump:
if not isinstance(dbTables, dict): if not isinstance(dbTables, dict):
self.string(TABLES_ELEM_NAME, dbTables) self.string(TABLES_ELEM_NAME, dbTables)
return return
dbTablesElem = self.__doc.createElement(DB_TABLES_ELEM_NAME) dbTablesElem = self.__doc.createElement(DB_TABLES_ELEM_NAME)
for db, tables in dbTables.items(): for db, tables in dbTables.items():
@ -343,11 +343,11 @@ class XMLDump:
''' '''
Adds information about the columns of the existing tables to the xml Adds information about the columns of the existing tables to the xml
''' '''
columnsElem = self.__getRootChild(COLUMNS_ELEM_NAME) columnsElem = self.__getRootChild(COLUMNS_ELEM_NAME)
if not(columnsElem): if not(columnsElem):
columnsElem = self.__doc.createElement(COLUMNS_ELEM_NAME) columnsElem = self.__doc.createElement(COLUMNS_ELEM_NAME)
for db, tables in tableColumns.items(): for db, tables in tableColumns.items():
if not db: if not db:
db = DEFAULT_DB db = DEFAULT_DB
@ -358,7 +358,7 @@ class XMLDump:
for table, columns in tables.items(): for table, columns in tables.items():
tableElem = self.__doc.createElement(TABLE_ELEM_NAME) tableElem = self.__doc.createElement(TABLE_ELEM_NAME)
tableElem.setAttributeNode(self.__createAttribute(NAME_ATTR, table)) tableElem.setAttributeNode(self.__createAttribute(NAME_ATTR, table))
colList = columns.keys() colList = columns.keys()
colList.sort(key=lambda x: x.lower()) colList.sort(key=lambda x: x.lower())
@ -368,10 +368,10 @@ class XMLDump:
if colType is not None: if colType is not None:
colElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, colType)) colElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, colType))
else : else :
colElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNKNOWN_COLUMN_TYPE)) colElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNKNOWN_COLUMN_TYPE))
colElem.appendChild(self.__createTextNode(column)) colElem.appendChild(self.__createTextNode(column))
tableElem.appendChild(colElem) tableElem.appendChild(colElem)
self.__addToRoot(columnsElem) self.__addToRoot(columnsElem)
def dbTableValues(self, tableValues): def dbTableValues(self, tableValues):
@ -380,19 +380,19 @@ class XMLDump:
The values are organized according to the relevant row and column. The values are organized according to the relevant row and column.
''' '''
tableElem = self.__doc.createElement(DB_TABLE_VALUES_ELEM_NAME) tableElem = self.__doc.createElement(DB_TABLE_VALUES_ELEM_NAME)
if (tableValues is not None): if (tableValues is not None):
db = tableValues["__infos__"]["db"] db = tableValues["__infos__"]["db"]
if not db: if not db:
db = "All" db = "All"
table = tableValues["__infos__"]["table"] table = tableValues["__infos__"]["table"]
count = int(tableValues["__infos__"]["count"]) count = int(tableValues["__infos__"]["count"])
columns = tableValues.keys() columns = tableValues.keys()
columns.sort(key=lambda x: x.lower()) columns.sort(key=lambda x: x.lower())
tableElem.setAttributeNode(self.__createAttribute(DB_ATTR, db)) tableElem.setAttributeNode(self.__createAttribute(DB_ATTR, db))
tableElem.setAttributeNode(self.__createAttribute(NAME_ATTR, table)) tableElem.setAttributeNode(self.__createAttribute(NAME_ATTR, table))
for i in range(count): for i in range(count):
rowElem = self.__doc.createElement(ROW_ELEM_NAME) rowElem = self.__doc.createElement(ROW_ELEM_NAME)
tableElem.appendChild(rowElem) tableElem.appendChild(rowElem)
@ -400,27 +400,27 @@ class XMLDump:
if column != "__infos__": if column != "__infos__":
info = tableValues[column] info = tableValues[column]
value = info["values"][i] value = info["values"][i]
if re.search("^[\ *]*$", value): if re.search("^[\ *]*$", value):
value = "NULL" value = "NULL"
cellElem = self.__doc.createElement(CELL_ELEM_NAME) cellElem = self.__doc.createElement(CELL_ELEM_NAME)
cellElem.setAttributeNode(self.__createAttribute(COLUMN_ATTR, column)) cellElem.setAttributeNode(self.__createAttribute(COLUMN_ATTR, column))
cellElem.appendChild(self.__createTextNode(value)) cellElem.appendChild(self.__createTextNode(value))
rowElem.appendChild(cellElem) rowElem.appendChild(cellElem)
dbValuesElem = self.__getRootChild(DB_VALUES_ELEM) dbValuesElem = self.__getRootChild(DB_VALUES_ELEM)
if (not(dbValuesElem)): if (not(dbValuesElem)):
dbValuesElem = self.__doc.createElement(DB_VALUES_ELEM) dbValuesElem = self.__doc.createElement(DB_VALUES_ELEM)
self.__addToRoot(dbValuesElem) self.__addToRoot(dbValuesElem)
dbValuesElem.appendChild(tableElem) dbValuesElem.appendChild(tableElem)
logger.info("Table '%s.%s' dumped to XML file" % (db, table)) logger.info("Table '%s.%s' dumped to XML file" % (db, table))
def dbColumns(self, dbColumns, colConsider, dbs): def dbColumns(self, dbColumns, colConsider, dbs):
''' '''
Adds information about the columns Adds information about the columns
''' '''
for column in dbColumns.keys(): for column in dbColumns.keys():
printDbs = {} printDbs = {}
@ -494,7 +494,7 @@ class XMLDump:
self.__outputFP = codecs.open(self.__outputFile, "w+", conf.dataEncoding) self.__outputFP = codecs.open(self.__outputFile, "w+", conf.dataEncoding)
if self.__root is None: if self.__root is None:
self.__root = self.__doc.createElementNS(NAME_SPACE_ATTR, RESULTS_ELEM_NAME) self.__root = self.__doc.createElementNS(NAME_SPACE_ATTR, RESULTS_ELEM_NAME)
self.__root.setAttributeNode(self.__createAttribute(XMLNS_ATTR,NAME_SPACE_ATTR)) self.__root.setAttributeNode(self.__createAttribute(XMLNS_ATTR,NAME_SPACE_ATTR))
self.__root.setAttributeNode(self.__createAttribute(SCHEME_NAME_ATTR,SCHEME_NAME)) self.__root.setAttributeNode(self.__createAttribute(SCHEME_NAME_ATTR,SCHEME_NAME))