more unicode refactoring

This commit is contained in:
Miroslav Stampar
2010-06-02 12:45:40 +00:00
parent 2fb8bf3b6a
commit 12a5ec9f3d
16 changed files with 37 additions and 23 deletions

View File

@@ -1354,7 +1354,7 @@ def getCommonStart(strings=[]):
def getUnicode(value):
if isinstance(value, basestring):
return value if isinstance(value, unicode) else unicode(value, conf.dataEncoding)
return value if isinstance(value, unicode) else unicode(value, conf.dataEncoding if 'dataEncoding' in conf else "utf-8")
else:
return unicode(value)

View File

@@ -22,6 +22,7 @@ with sqlmap; if not, write to the Free Software Foundation, Inc., 51
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
from lib.core.common import getUnicode
from lib.core.common import dataToStdout
from lib.core.data import conf
@@ -80,7 +81,7 @@ class ProgressBar:
" " * (allFull - numHashes))
# Add the percentage at the beginning of the progress bar
percentString = unicode(percentDone) + "%"
percentString = getUnicode(percentDone) + "%"
self.__progBar = "%s %s" % (percentString, self.__progBar)
def draw(self, eta=0):
@@ -102,4 +103,4 @@ class ProgressBar:
This method returns the progress bar string
"""
return unicode(self.__progBar)
return getUnicode(self.__progBar)

View File

@@ -39,6 +39,7 @@ from xml.dom.minidom import Document
from subprocess import PIPE
from subprocess import Popen as execute
from lib.core.common import getUnicode
from lib.core.common import dataToStdout
from lib.core.common import pollProcess
from lib.core.common import readInput
@@ -215,7 +216,7 @@ def __updateSqlmap():
logger.debug(debugMsg)
def notify(event_dict):
action = unicode(event_dict['action'])
action = getUnicode(event_dict['action'])
index = action.find('_')
prefix = action[index + 1].upper() if index != -1 else action.capitalize()
@@ -225,7 +226,7 @@ def __updateSqlmap():
if action.find('_completed') == -1:
print "%s\t%s" % (prefix, event_dict['path'])
else:
revision = unicode(event_dict['revision'])
revision = getUnicode(event_dict['revision'])
index = revision.find('number ')
if index != -1: