Replace conv_to_unicode_direct with str
This commit is contained in:
parent
66c410f55e
commit
8c18eae777
@ -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.plug.report._paper import paper_sizes
|
||||||
from gramps.gen.const import USER_HOME
|
from gramps.gen.const import USER_HOME
|
||||||
from gramps.gen.dbstate import DbState
|
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 ..grampscli import CLIManager
|
||||||
from ..user import User
|
from ..user import User
|
||||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
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 \
|
if ( str_val.startswith("'") and str_val.endswith("'") ) or \
|
||||||
( str_val.startswith('"') and str_val.endswith('"') ):
|
( str_val.startswith('"') and str_val.endswith('"') ):
|
||||||
# Remove enclosing quotes
|
# Remove enclosing quotes
|
||||||
return conv_to_unicode_direct(str_val[1:-1])
|
return str(str_val[1:-1])
|
||||||
else:
|
else:
|
||||||
return conv_to_unicode_direct(str_val)
|
return str(str_val)
|
||||||
|
|
||||||
elif ret_type == int:
|
elif ret_type == int:
|
||||||
if str_val.isdigit():
|
if str_val.isdigit():
|
||||||
|
@ -51,10 +51,9 @@ WINDOWS = ["Windows", "win32"]
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
conv_to_unicode_direct = str
|
|
||||||
STRTYPE = str
|
STRTYPE = str
|
||||||
UNITYPE = str
|
UNITYPE = str
|
||||||
cuni = conv_to_unicode_direct
|
cuni = str
|
||||||
def conv_to_unicode(x, y='utf8'):
|
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)
|
return x if x is None or isinstance(x, UNITYPE) else cuni(x, y) if y else cuni(x)
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@ import re
|
|||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger(".")
|
LOG = logging.getLogger(".")
|
||||||
|
|
||||||
from ...constfunc import conv_to_unicode_direct
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Rule
|
# Rule
|
||||||
@ -85,7 +83,7 @@ class Rule(object):
|
|||||||
if self.list[i]:
|
if self.list[i]:
|
||||||
try:
|
try:
|
||||||
self.regex[i] = re.compile(
|
self.regex[i] = re.compile(
|
||||||
conv_to_unicode_direct(self.list[i]),
|
str(self.list[i]),
|
||||||
re.I|re.U|re.L)
|
re.I|re.U|re.L)
|
||||||
except re.error:
|
except re.error:
|
||||||
self.regex[i] = re.compile('')
|
self.regex[i] = re.compile('')
|
||||||
@ -152,7 +150,7 @@ class Rule(object):
|
|||||||
"""
|
"""
|
||||||
# make str_var unicode so that search for ü works
|
# make str_var unicode so that search for ü works
|
||||||
# see issue 3188
|
# see issue 3188
|
||||||
str_var = conv_to_unicode_direct(str_var)
|
str_var = str(str_var)
|
||||||
if self.list[param_index] and \
|
if self.list[param_index] and \
|
||||||
(str_var.upper().find(self.list[param_index].upper()) == -1):
|
(str_var.upper().find(self.list[param_index].upper()) == -1):
|
||||||
return False
|
return False
|
||||||
@ -165,7 +163,7 @@ class Rule(object):
|
|||||||
matches filter element indicated by param_index using a regular
|
matches filter element indicated by param_index using a regular
|
||||||
expression search.
|
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)
|
if (self.list[param_index] and self.regex[param_index].search(str_var)
|
||||||
is None):
|
is None):
|
||||||
return False
|
return False
|
||||||
|
@ -34,7 +34,6 @@ _ = glocale.translation.gettext
|
|||||||
from ....utils.alive import probably_alive
|
from ....utils.alive import probably_alive
|
||||||
from .. import Rule
|
from .. import Rule
|
||||||
from ....datehandler import parser
|
from ....datehandler import parser
|
||||||
from ....constfunc import conv_to_unicode_direct
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# "People probably alive"
|
# "People probably alive"
|
||||||
@ -49,7 +48,7 @@ class ProbablyAlive(Rule):
|
|||||||
|
|
||||||
def prepare(self,db):
|
def prepare(self,db):
|
||||||
try:
|
try:
|
||||||
self.current_date = parser.parse(conv_to_unicode_direct(self.list[0]))
|
self.current_date = parser.parse(str(self.list[0]))
|
||||||
except:
|
except:
|
||||||
self.current_date = None
|
self.current_date = None
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ from ..lib import (Person, Family, Event, Source, Place, Citation,
|
|||||||
Repository, MediaObject, Note, Date, Span)
|
Repository, MediaObject, Note, Date, Span)
|
||||||
from ..config import config
|
from ..config import config
|
||||||
from ..datehandler import displayer
|
from ..datehandler import displayer
|
||||||
from ..constfunc import STRTYPE, conv_to_unicode_direct
|
from ..constfunc import STRTYPE
|
||||||
|
|
||||||
class SimpleTable(object):
|
class SimpleTable(object):
|
||||||
"""
|
"""
|
||||||
@ -70,7 +70,7 @@ class SimpleTable(object):
|
|||||||
"""
|
"""
|
||||||
Set the columns
|
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))]
|
self._sort_vals = [[] for i in range(len(self._columns))]
|
||||||
|
|
||||||
def row_sort_val(self, col, val):
|
def row_sort_val(self, col, val):
|
||||||
@ -107,7 +107,7 @@ class SimpleTable(object):
|
|||||||
else:
|
else:
|
||||||
retval.append(item)
|
retval.append(item)
|
||||||
elif isinstance(item, (int, float)):
|
elif isinstance(item, (int, float)):
|
||||||
retval.append(conv_to_unicode_direct(item))
|
retval.append(str(item))
|
||||||
self.row_sort_val(col, item)
|
self.row_sort_val(col, item)
|
||||||
elif isinstance(item, bool):
|
elif isinstance(item, bool):
|
||||||
retval.append(repr(item))
|
retval.append(repr(item))
|
||||||
@ -166,7 +166,7 @@ class SimpleTable(object):
|
|||||||
if (self._link_col == col or link is None):
|
if (self._link_col == col or link is None):
|
||||||
link = ('Date', item)
|
link = ('Date', item)
|
||||||
elif isinstance(item, Span):
|
elif isinstance(item, Span):
|
||||||
text = conv_to_unicode_direct(item)
|
text = str(item)
|
||||||
retval.append(text)
|
retval.append(text)
|
||||||
self.row_sort_val(col, item)
|
self.row_sort_val(col, item)
|
||||||
elif isinstance(item, list): # [text, "PersonList", handle, ...]
|
elif isinstance(item, list): # [text, "PersonList", handle, ...]
|
||||||
@ -239,7 +239,7 @@ class SimpleTable(object):
|
|||||||
else:
|
else:
|
||||||
doc.start_link("/%s/%s" %
|
doc.start_link("/%s/%s" %
|
||||||
(obj_type.lower(), handle))
|
(obj_type.lower(), handle))
|
||||||
doc.write_text(conv_to_unicode_direct(col), 'Normal')
|
doc.write_text(str(col), 'Normal')
|
||||||
if obj_type and handle:
|
if obj_type and handle:
|
||||||
doc.stop_link()
|
doc.stop_link()
|
||||||
doc.end_cell()
|
doc.end_cell()
|
||||||
|
@ -38,8 +38,6 @@ IGNORE = "HW~!@#$%^&*()_+=-`[]\|;:'/?.,<>\" \t\f\v"
|
|||||||
TABLE = bytes.maketrans(b'ABCDEFGIJKLMNOPQRSTUVXYZ',
|
TABLE = bytes.maketrans(b'ABCDEFGIJKLMNOPQRSTUVXYZ',
|
||||||
b'012301202245501262301202')
|
b'012301202245501262301202')
|
||||||
|
|
||||||
from .constfunc import conv_to_unicode_direct
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# soundex - returns the soundex value for the specified string
|
# soundex - returns the soundex value for the specified string
|
||||||
@ -49,7 +47,7 @@ def soundex(strval):
|
|||||||
"Return the soundex value to a string argument."
|
"Return the soundex value to a string argument."
|
||||||
|
|
||||||
strval = unicodedata.normalize('NFKD',
|
strval = unicodedata.normalize('NFKD',
|
||||||
conv_to_unicode_direct(strval.upper().strip())).encode('ASCII', 'ignore')
|
str(strval.upper().strip())).encode('ASCII', 'ignore')
|
||||||
if not strval:
|
if not strval:
|
||||||
return "Z000"
|
return "Z000"
|
||||||
strval = strval.decode('ASCII', 'ignore')
|
strval = strval.decode('ASCII', 'ignore')
|
||||||
|
@ -41,7 +41,7 @@ LOG = logging.getLogger(".")
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from ..const import GRAMPS_LOCALE as glocale
|
from ..const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.gettext
|
_ = 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
|
#strings in database are utf-8
|
||||||
conv_dbstr_to_unicode = lambda x: conv_to_unicode(x, 'UTF-8')
|
conv_dbstr_to_unicode = lambda x: conv_to_unicode(x, 'UTF-8')
|
||||||
|
Loading…
Reference in New Issue
Block a user