Replace conv_to_unicode_direct with str

This commit is contained in:
Nick Hall 2015-03-14 21:49:45 +00:00 committed by Ross Gammon
parent 66c410f55e
commit 8c18eae777
7 changed files with 15 additions and 21 deletions

View File

@ -59,7 +59,7 @@ from gramps.gen.plug.report import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK,
from gramps.gen.plug.report._paper import paper_sizes
from gramps.gen.const import USER_HOME
from gramps.gen.dbstate import DbState
from gramps.gen.constfunc import STRTYPE, conv_to_unicode_direct
from gramps.gen.constfunc import STRTYPE
from ..grampscli import CLIManager
from ..user import User
from gramps.gen.const import GRAMPS_LOCALE as glocale
@ -81,9 +81,9 @@ def _convert_str_to_match_type(str_val, type_val):
if ( str_val.startswith("'") and str_val.endswith("'") ) or \
( str_val.startswith('"') and str_val.endswith('"') ):
# Remove enclosing quotes
return conv_to_unicode_direct(str_val[1:-1])
return str(str_val[1:-1])
else:
return conv_to_unicode_direct(str_val)
return str(str_val)
elif ret_type == int:
if str_val.isdigit():

View File

@ -51,10 +51,9 @@ WINDOWS = ["Windows", "win32"]
#
#-------------------------------------------------------------------------
conv_to_unicode_direct = str
STRTYPE = str
UNITYPE = str
cuni = conv_to_unicode_direct
cuni = str
def conv_to_unicode(x, y='utf8'):
return x if x is None or isinstance(x, UNITYPE) else cuni(x, y) if y else cuni(x)

View File

@ -40,8 +40,6 @@ import re
import logging
LOG = logging.getLogger(".")
from ...constfunc import conv_to_unicode_direct
#-------------------------------------------------------------------------
#
# Rule
@ -85,7 +83,7 @@ class Rule(object):
if self.list[i]:
try:
self.regex[i] = re.compile(
conv_to_unicode_direct(self.list[i]),
str(self.list[i]),
re.I|re.U|re.L)
except re.error:
self.regex[i] = re.compile('')
@ -152,7 +150,7 @@ class Rule(object):
"""
# make str_var unicode so that search for ü works
# see issue 3188
str_var = conv_to_unicode_direct(str_var)
str_var = str(str_var)
if self.list[param_index] and \
(str_var.upper().find(self.list[param_index].upper()) == -1):
return False
@ -165,7 +163,7 @@ class Rule(object):
matches filter element indicated by param_index using a regular
expression search.
"""
str_var = conv_to_unicode_direct(str_var)
str_var = str(str_var)
if (self.list[param_index] and self.regex[param_index].search(str_var)
is None):
return False

View File

@ -34,7 +34,6 @@ _ = glocale.translation.gettext
from ....utils.alive import probably_alive
from .. import Rule
from ....datehandler import parser
from ....constfunc import conv_to_unicode_direct
#-------------------------------------------------------------------------
# "People probably alive"
@ -49,7 +48,7 @@ class ProbablyAlive(Rule):
def prepare(self,db):
try:
self.current_date = parser.parse(conv_to_unicode_direct(self.list[0]))
self.current_date = parser.parse(str(self.list[0]))
except:
self.current_date = None

View File

@ -31,7 +31,7 @@ from ..lib import (Person, Family, Event, Source, Place, Citation,
Repository, MediaObject, Note, Date, Span)
from ..config import config
from ..datehandler import displayer
from ..constfunc import STRTYPE, conv_to_unicode_direct
from ..constfunc import STRTYPE
class SimpleTable(object):
"""
@ -70,7 +70,7 @@ class SimpleTable(object):
"""
Set the columns
"""
self._columns = [conv_to_unicode_direct(col) for col in cols]
self._columns = [str(col) for col in cols]
self._sort_vals = [[] for i in range(len(self._columns))]
def row_sort_val(self, col, val):
@ -107,7 +107,7 @@ class SimpleTable(object):
else:
retval.append(item)
elif isinstance(item, (int, float)):
retval.append(conv_to_unicode_direct(item))
retval.append(str(item))
self.row_sort_val(col, item)
elif isinstance(item, bool):
retval.append(repr(item))
@ -166,7 +166,7 @@ class SimpleTable(object):
if (self._link_col == col or link is None):
link = ('Date', item)
elif isinstance(item, Span):
text = conv_to_unicode_direct(item)
text = str(item)
retval.append(text)
self.row_sort_val(col, item)
elif isinstance(item, list): # [text, "PersonList", handle, ...]
@ -239,7 +239,7 @@ class SimpleTable(object):
else:
doc.start_link("/%s/%s" %
(obj_type.lower(), handle))
doc.write_text(conv_to_unicode_direct(col), 'Normal')
doc.write_text(str(col), 'Normal')
if obj_type and handle:
doc.stop_link()
doc.end_cell()

View File

@ -38,8 +38,6 @@ IGNORE = "HW~!@#$%^&*()_+=-`[]\|;:'/?.,<>\" \t\f\v"
TABLE = bytes.maketrans(b'ABCDEFGIJKLMNOPQRSTUVXYZ',
b'012301202245501262301202')
from .constfunc import conv_to_unicode_direct
#-------------------------------------------------------------------------
#
# soundex - returns the soundex value for the specified string
@ -49,7 +47,7 @@ def soundex(strval):
"Return the soundex value to a string argument."
strval = unicodedata.normalize('NFKD',
conv_to_unicode_direct(strval.upper().strip())).encode('ASCII', 'ignore')
str(strval.upper().strip())).encode('ASCII', 'ignore')
if not strval:
return "Z000"
strval = strval.decode('ASCII', 'ignore')

View File

@ -41,7 +41,7 @@ LOG = logging.getLogger(".")
#-------------------------------------------------------------------------
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from ..constfunc import conv_to_unicode, conv_to_unicode_direct, UNITYPE, STRTYPE
from ..constfunc import conv_to_unicode, UNITYPE, STRTYPE
#strings in database are utf-8
conv_dbstr_to_unicode = lambda x: conv_to_unicode(x, 'UTF-8')