Replace STRTYPE with str
This commit is contained in:
parent
6d047c946c
commit
beab7892e5
@ -59,7 +59,6 @@ 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
|
||||
from ..grampscli import CLIManager
|
||||
from ..user import User
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
@ -77,7 +76,7 @@ def _convert_str_to_match_type(str_val, type_val):
|
||||
str_val = str_val.strip()
|
||||
ret_type = type(type_val)
|
||||
|
||||
if isinstance(type_val, STRTYPE):
|
||||
if isinstance(type_val, str):
|
||||
if ( str_val.startswith("'") and str_val.endswith("'") ) or \
|
||||
( str_val.startswith('"') and str_val.endswith('"') ):
|
||||
# Remove enclosing quotes
|
||||
|
@ -51,7 +51,6 @@ WINDOWS = ["Windows", "win32"]
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
STRTYPE = str
|
||||
UNITYPE = str
|
||||
cuni = str
|
||||
def conv_to_unicode(x, y='utf8'):
|
||||
|
@ -52,7 +52,6 @@ from ..lib.place import Place
|
||||
from ..lib.repo import Repository
|
||||
from ..lib.note import Note
|
||||
from ..lib.tag import Tag
|
||||
from ..constfunc import STRTYPE
|
||||
|
||||
class Cursor(object):
|
||||
"""
|
||||
@ -298,7 +297,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
|
||||
@staticmethod
|
||||
def _validated_id_prefix(val, default):
|
||||
if isinstance(val, STRTYPE) and val:
|
||||
if isinstance(val, str) and val:
|
||||
try:
|
||||
str_ = val % 1
|
||||
except TypeError: # missing conversion specifier
|
||||
|
@ -73,7 +73,7 @@ from ..utils.cast import conv_dbstr_to_unicode
|
||||
from . import (BsddbBaseCursor, DbReadBase)
|
||||
from ..utils.id import create_id
|
||||
from ..errors import DbError
|
||||
from ..constfunc import UNITYPE, STRTYPE, cuni, handle2internal, get_env_var
|
||||
from ..constfunc import UNITYPE, cuni, handle2internal, get_env_var
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -1278,7 +1278,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
|
||||
@staticmethod
|
||||
def _validated_id_prefix(val, default):
|
||||
if isinstance(val, STRTYPE) and val:
|
||||
if isinstance(val, str) and val:
|
||||
try:
|
||||
str_ = val % 1
|
||||
except TypeError: # missing conversion specifier
|
||||
|
@ -36,7 +36,6 @@ import io
|
||||
#-------------------------------------------------------------------------
|
||||
from ._filterparser import FilterParser
|
||||
from ..plug import BasePluginManager
|
||||
from ..constfunc import STRTYPE
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
|
||||
PLUGMAN = BasePluginManager.get_instance()
|
||||
@ -94,7 +93,7 @@ class FilterList(object):
|
||||
return filters
|
||||
|
||||
def add(self, namespace, filt):
|
||||
assert(isinstance(namespace, STRTYPE))
|
||||
assert(isinstance(namespace, str))
|
||||
|
||||
if namespace not in self.filter_namespaces:
|
||||
self.filter_namespaces[namespace] = []
|
||||
|
@ -31,7 +31,6 @@ AttributeRootBase class for Gramps.
|
||||
from .attribute import Attribute
|
||||
from .srcattribute import SrcAttribute
|
||||
from .const import IDENTICAL, EQUAL
|
||||
from ..constfunc import STRTYPE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -111,7 +110,7 @@ class AttributeRootBase(object):
|
||||
:param attribute: :class:`~.attribute.Attribute` instance to add.
|
||||
:type attribute: :class:`~.attribute.Attribute`
|
||||
"""
|
||||
assert not isinstance(attribute, STRTYPE)
|
||||
assert not isinstance(attribute, str)
|
||||
self.attribute_list.append(attribute)
|
||||
|
||||
def remove_attribute(self, attribute):
|
||||
|
@ -30,7 +30,7 @@ Base type for all gramps types.
|
||||
#-------------------------------------------------------------------------
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ..constfunc import STRTYPE, cuni
|
||||
from ..constfunc import cuni
|
||||
|
||||
_UNKNOWN = _('Unknown')
|
||||
|
||||
@ -168,7 +168,7 @@ class GrampsType(GrampsTypeC):
|
||||
self.__set_int(value)
|
||||
elif isinstance(value, self.__class__):
|
||||
self.__set_instance(value)
|
||||
elif isinstance(value, STRTYPE):
|
||||
elif isinstance(value, str):
|
||||
self.__set_str(value)
|
||||
else:
|
||||
self.__value = self._DEFAULT
|
||||
@ -294,7 +294,7 @@ class GrampsType(GrampsTypeC):
|
||||
def __eq__(self, value):
|
||||
if isinstance(value, int):
|
||||
return self.__value == value
|
||||
elif isinstance(value, STRTYPE):
|
||||
elif isinstance(value, str):
|
||||
if self.__value == self._CUSTOM:
|
||||
return self.__string == value
|
||||
else:
|
||||
@ -315,10 +315,10 @@ class GrampsType(GrampsTypeC):
|
||||
|
||||
## Python 3 does not have __cmp__
|
||||
## def __cmp__(self, value):
|
||||
## print ('cmp', type(value), STRTYPE)
|
||||
## print ('cmp', type(value), str)
|
||||
## if isinstance(value, int):
|
||||
## return cmp(self.__value, value)
|
||||
## elif isinstance(value, STRTYPE):
|
||||
## elif isinstance(value, str):
|
||||
## print('ok!')
|
||||
## if self.__value == self._CUSTOM:
|
||||
## return cmp(self.__string, value)
|
||||
|
@ -48,7 +48,6 @@ from .attribute import Attribute
|
||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ..constfunc import STRTYPE
|
||||
from .handle import Handle
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -997,7 +996,7 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
|
||||
to the Person's :class:`~.family.Family` list.
|
||||
:type family_handle: str
|
||||
"""
|
||||
if not isinstance(family_handle, STRTYPE):
|
||||
if not isinstance(family_handle, str):
|
||||
raise ValueError("Expecting handle, obtained %s" % str(family_handle))
|
||||
if family_handle not in self.parent_family_list:
|
||||
self.parent_family_list.append(family_handle)
|
||||
|
@ -27,7 +27,7 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from .styledtexttag import StyledTextTag
|
||||
from ..constfunc import cuni, STRTYPE
|
||||
from ..constfunc import cuni
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -111,7 +111,7 @@ class StyledText(object):
|
||||
|
||||
return self.__class__("".join([self._string, other._string]),
|
||||
self._tags + other._tags)
|
||||
elif isinstance(other, STRTYPE):
|
||||
elif isinstance(other, str):
|
||||
# tags remain the same, only text becomes longer
|
||||
return self.__class__("".join([self._string, other]), self._tags)
|
||||
else:
|
||||
|
@ -51,7 +51,7 @@ _ = glocale.translation.gettext
|
||||
#-------------------------------------------------------------------------
|
||||
from ..config import config
|
||||
from . import PluginRegister, ImportPlugin, ExportPlugin, DocGenPlugin
|
||||
from ..constfunc import STRTYPE, win
|
||||
from ..constfunc import win
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -245,7 +245,7 @@ class BasePluginManager(object):
|
||||
to sys.path first (if needed), import, and then reset path.
|
||||
"""
|
||||
module = None
|
||||
if isinstance(pdata, STRTYPE):
|
||||
if isinstance(pdata, str):
|
||||
pdata = self.get_plugin(pdata)
|
||||
if not pdata:
|
||||
return None
|
||||
|
@ -44,7 +44,6 @@ from ...version import VERSION as GRAMPSVERSION, VERSION_TUPLE
|
||||
from ..const import IMAGE_DIR
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ..constfunc import STRTYPE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -162,7 +161,7 @@ def valid_plugin_version(plugin_version_string):
|
||||
Checks to see if string is a valid version string for this version
|
||||
of Gramps.
|
||||
"""
|
||||
if not isinstance(plugin_version_string, STRTYPE): return False
|
||||
if not isinstance(plugin_version_string, str): return False
|
||||
dots = plugin_version_string.count(".")
|
||||
if dots == 1:
|
||||
plugin_version = tuple(map(int, plugin_version_string.split(".", 1)))
|
||||
|
@ -36,7 +36,6 @@ from ..lib import EventType
|
||||
from ..config import config
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ..constfunc import STRTYPE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -123,7 +122,7 @@ class SimpleAccess(object):
|
||||
:return: Returns the name of the person based of the program preferences
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
if person:
|
||||
@ -140,7 +139,7 @@ class SimpleAccess(object):
|
||||
:return: Returns the name of the person based of the program preferences
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
if person:
|
||||
@ -160,7 +159,7 @@ class SimpleAccess(object):
|
||||
preferences
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
if person:
|
||||
@ -191,7 +190,7 @@ class SimpleAccess(object):
|
||||
:return: Returns a string indentifying the person's gender
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
if person:
|
||||
@ -319,7 +318,7 @@ class SimpleAccess(object):
|
||||
:return: The spouse identified as the person's primary spouse
|
||||
:rtype: :py:class:`.Person`
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
|
||||
@ -347,7 +346,7 @@ class SimpleAccess(object):
|
||||
person and his/per primary spouse.
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
|
||||
@ -371,7 +370,7 @@ class SimpleAccess(object):
|
||||
his/her spouse where married.
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
|
||||
@ -402,7 +401,7 @@ class SimpleAccess(object):
|
||||
his/her spouse where married.
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
|
||||
@ -494,7 +493,7 @@ class SimpleAccess(object):
|
||||
:return: Returns a string indicating the date when the person's birth.
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_date(person, Person.get_birth_ref)
|
||||
|
||||
@ -507,7 +506,7 @@ class SimpleAccess(object):
|
||||
:return: Returns the date when the person's birth.
|
||||
:rtype: :py:class:`.Date`
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_date_obj(person, Person.get_birth_ref)
|
||||
|
||||
@ -521,7 +520,7 @@ class SimpleAccess(object):
|
||||
:return: Returns the date when the person's birth or fallback.
|
||||
:rtype: :py:class:`.Date`
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
event = get_birth_or_fallback(self.dbase, person, "<i>%s</i>")
|
||||
if get_event:
|
||||
@ -540,7 +539,7 @@ class SimpleAccess(object):
|
||||
:return: Returns a string indicating the place of the person's birth.
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_place(person, Person.get_birth_ref)
|
||||
|
||||
@ -553,7 +552,7 @@ class SimpleAccess(object):
|
||||
:return: Returns a string indicating the date when the person's death.
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_date(person, Person.get_death_ref)
|
||||
|
||||
@ -566,7 +565,7 @@ class SimpleAccess(object):
|
||||
:return: Returns the date when the person's death.
|
||||
:rtype: :py:class:`.Date`
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_date_obj(person, Person.get_death_ref)
|
||||
|
||||
@ -579,7 +578,7 @@ class SimpleAccess(object):
|
||||
:return: Returns the date of the person's death or fallback.
|
||||
:rtype: :py:class:`.Date`
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
event = get_death_or_fallback(self.dbase, person, "<i>%s</i>")
|
||||
if get_event:
|
||||
@ -598,7 +597,7 @@ class SimpleAccess(object):
|
||||
:return: Returns a string indicating the place of the person's death.
|
||||
:rtype: unicode
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_place(person, Person.get_death_ref)
|
||||
|
||||
@ -732,7 +731,7 @@ class SimpleAccess(object):
|
||||
listed as a parent.
|
||||
:rtype: list
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
|
||||
@ -751,7 +750,7 @@ class SimpleAccess(object):
|
||||
listed as a child.
|
||||
:rtype: list
|
||||
"""
|
||||
if isinstance(person, STRTYPE):
|
||||
if isinstance(person, str):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(person is None or isinstance(person, Person))
|
||||
|
||||
@ -940,15 +939,15 @@ class SimpleAccess(object):
|
||||
return ''
|
||||
|
||||
def person(self, handle):
|
||||
assert(isinstance(handle, STRTYPE))
|
||||
assert(isinstance(handle, str))
|
||||
return self.dbase.get_person_from_handle(handle)
|
||||
|
||||
def event(self, handle):
|
||||
assert(isinstance(handle, STRTYPE))
|
||||
assert(isinstance(handle, str))
|
||||
return self.dbase.get_event_from_handle(handle)
|
||||
|
||||
def family(self, handle):
|
||||
assert(isinstance(handle, STRTYPE))
|
||||
assert(isinstance(handle, str))
|
||||
return self.dbase.get_family_from_handle(handle)
|
||||
|
||||
def display(self, object_class, prop, value):
|
||||
|
@ -31,7 +31,6 @@ 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
|
||||
|
||||
class SimpleTable(object):
|
||||
"""
|
||||
@ -100,7 +99,7 @@ class SimpleTable(object):
|
||||
# FIXME: add better text representations of these objects
|
||||
if item is None:
|
||||
retval.append("")
|
||||
elif isinstance(item, STRTYPE):
|
||||
elif isinstance(item, str):
|
||||
if item == "checkbox":
|
||||
retval.append(False)
|
||||
self.set_cell_type(col, "checkbox")
|
||||
|
@ -41,7 +41,7 @@ LOG = logging.getLogger(".")
|
||||
#-------------------------------------------------------------------------
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ..constfunc import conv_to_unicode, UNITYPE, STRTYPE
|
||||
from ..constfunc import conv_to_unicode, UNITYPE
|
||||
|
||||
#strings in database are utf-8
|
||||
conv_dbstr_to_unicode = lambda x: conv_to_unicode(x, 'UTF-8')
|
||||
@ -54,7 +54,7 @@ def get_type_converter(val):
|
||||
Return function that converts strings into the type of val.
|
||||
"""
|
||||
val_type = type(val)
|
||||
if isinstance(val, STRTYPE):
|
||||
if isinstance(val, str):
|
||||
return str
|
||||
elif val_type == int:
|
||||
return int
|
||||
@ -79,7 +79,7 @@ def type_name(val):
|
||||
return 'float'
|
||||
elif val_type == bool:
|
||||
return 'bool'
|
||||
elif isinstance(val, STRTYPE):
|
||||
elif isinstance(val, str):
|
||||
return 'unicode'
|
||||
return 'unicode'
|
||||
|
||||
|
@ -38,7 +38,6 @@ import copy
|
||||
import logging
|
||||
import io
|
||||
|
||||
from ..constfunc import STRTYPE
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -153,7 +152,7 @@ class ConfigManager(object):
|
||||
use_plugins_path=False)
|
||||
# will use /tmp/Other.ini
|
||||
"""
|
||||
if isinstance(override, STRTYPE): # directory or filename
|
||||
if isinstance(override, str): # directory or filename
|
||||
if override:
|
||||
path, ininame = os.path.split(os.path.abspath(override))
|
||||
else:
|
||||
@ -544,8 +543,8 @@ class ConfigManager(object):
|
||||
type2 = type(value2)
|
||||
if type1 == type2:
|
||||
return True
|
||||
elif (isinstance(value1, STRTYPE) and
|
||||
isinstance(value2, STRTYPE)):
|
||||
elif (isinstance(value1, str) and
|
||||
isinstance(value2, str)):
|
||||
return True
|
||||
elif (type1 in [int, float] and
|
||||
type2 in [int, float]):
|
||||
|
@ -30,7 +30,6 @@ Provide autocompletion functionality.
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GObject
|
||||
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
@ -266,7 +265,7 @@ class StandardCustomSelector(object):
|
||||
a string representing a custom type, an (int, str) tuple or an EventType
|
||||
instance.
|
||||
"""
|
||||
if isinstance(event_type, STRTYPE):
|
||||
if isinstance(event_type, str):
|
||||
return (self.custom_key, event_type)
|
||||
elif isinstance(event_type, tuple):
|
||||
if event_type[1]:
|
||||
|
@ -59,7 +59,7 @@ from .glade import Glade
|
||||
from .ddtargets import DdTargets
|
||||
from .makefilter import make_filter
|
||||
from .utils import is_right_click
|
||||
from gramps.gen.constfunc import cuni, STRTYPE
|
||||
from gramps.gen.constfunc import cuni
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -1125,7 +1125,7 @@ class ClipboardListView(object):
|
||||
def object_pixbuf(self, column, cell, model, node, user_data=None):
|
||||
o = model.get_value(node, 1)
|
||||
if o._dbid != self.dbstate.db.get_dbid():
|
||||
if isinstance(o.__class__.UNAVAILABLE_ICON, STRTYPE):
|
||||
if isinstance(o.__class__.UNAVAILABLE_ICON, str):
|
||||
cell.set_property('stock-id',
|
||||
o.__class__.UNAVAILABLE_ICON)
|
||||
else:
|
||||
@ -1237,7 +1237,7 @@ class ClipboardListView(object):
|
||||
dragtype = pickle.loads(sel_data)[0]
|
||||
except pickle.UnpicklingError as msg :
|
||||
# not a pickled object, probably text
|
||||
if isinstance(sel_data, STRTYPE):
|
||||
if isinstance(sel_data, str):
|
||||
dragtype = DdTargets.TEXT.drag_type
|
||||
if dragtype in self._target_type_to_wrapper_class_map:
|
||||
possible_wrappers = [dragtype]
|
||||
|
@ -64,7 +64,7 @@ from gramps.gen.db.exceptions import (DbUpgradeRequiredError,
|
||||
BsddbDowngradeRequiredError,
|
||||
PythonUpgradeRequiredError,
|
||||
PythonDowngradeError)
|
||||
from gramps.gen.constfunc import STRTYPE, UNITYPE, conv_to_unicode
|
||||
from gramps.gen.constfunc import conv_to_unicode
|
||||
from .pluginmanager import GuiPluginManager
|
||||
from .dialog import (DBErrorDialog, ErrorDialog, QuestionDialog2,
|
||||
WarningDialog)
|
||||
@ -210,7 +210,7 @@ class DbLoader(CLIDbLoader):
|
||||
In this process, a warning dialog can pop up.
|
||||
|
||||
"""
|
||||
if not isinstance(filename, (STRTYPE, UNITYPE)):
|
||||
if not isinstance(filename, str):
|
||||
return True
|
||||
|
||||
filename = os.path.normpath(os.path.abspath(filename))
|
||||
|
@ -26,8 +26,6 @@
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GObject
|
||||
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# This is used by plugins to create a menu of available filters
|
||||
@ -38,7 +36,7 @@ def build_filter_model(space, local = []):
|
||||
|
||||
model = Gtk.ListStore(GObject.TYPE_STRING, object)
|
||||
|
||||
if isinstance(space, STRTYPE):
|
||||
if isinstance(space, str):
|
||||
flist = local + CustomFilters.get_filters(space)
|
||||
elif isinstance(space, (list, tuple)):
|
||||
flist = space
|
||||
|
@ -47,7 +47,6 @@ from gi.repository import Gtk
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.const import GLADE_DIR, GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -203,7 +202,7 @@ class Glade(Gtk.Builder):
|
||||
if not toplevel:
|
||||
raise ValueError("Top level object required")
|
||||
|
||||
if isinstance(toplevel, STRTYPE):
|
||||
if isinstance(toplevel, str):
|
||||
toplevel = self.get_object(toplevel)
|
||||
|
||||
# Simple Breadth-First Search
|
||||
|
@ -59,7 +59,7 @@ from ..selectors import SelectorFactory
|
||||
from gramps.gen.display.name import displayer as _nd
|
||||
from gramps.gen.display.place import displayer as _pd
|
||||
from gramps.gen.filters import GenericFilterFactory, GenericFilter, rules
|
||||
from gramps.gen.constfunc import (conv_to_unicode, get_curr_dir, STRTYPE, cuni)
|
||||
from gramps.gen.constfunc import (conv_to_unicode, get_curr_dir, cuni)
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -407,7 +407,7 @@ class GuiTextOption(Gtk.ScrolledWindow):
|
||||
# we'll use that. If not, we'll assume a list and convert
|
||||
# it into a single string by assuming each list element
|
||||
# is separated by a newline.
|
||||
if isinstance(value, STRTYPE):
|
||||
if isinstance(value, str):
|
||||
self.__buff.set_text(value)
|
||||
|
||||
# Need to manually call the other handler so that the option
|
||||
@ -1250,7 +1250,7 @@ class GuiPersonListOption(Gtk.Box):
|
||||
"""
|
||||
value = self.__option.get_value()
|
||||
|
||||
if not isinstance(value, STRTYPE):
|
||||
if not isinstance(value, str):
|
||||
# Convert array into a string
|
||||
# (convienence so that programmers can
|
||||
# set value using a list)
|
||||
@ -1393,7 +1393,7 @@ class GuiPlaceListOption(Gtk.Box):
|
||||
"""
|
||||
value = self.__option.get_value()
|
||||
|
||||
if not isinstance(value, STRTYPE):
|
||||
if not isinstance(value, str):
|
||||
# Convert array into a string
|
||||
# (convienence so that programmers can
|
||||
# set value using a list)
|
||||
@ -1568,7 +1568,7 @@ class GuiSurnameColorOption(Gtk.Box):
|
||||
"""
|
||||
value = self.__option.get_value()
|
||||
|
||||
if not isinstance(value, STRTYPE):
|
||||
if not isinstance(value, str):
|
||||
# Convert dictionary into a string
|
||||
# (convienence so that programmers can
|
||||
# set value using a dictionary)
|
||||
|
@ -60,7 +60,6 @@ from gramps.gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY,
|
||||
CATEGORY_QR_NOTE, CATEGORY_QR_CITATION,
|
||||
CATEGORY_QR_SOURCE_OR_CITATION)
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
from ._textbufdoc import TextBufDoc
|
||||
from gramps.gen.simple import make_basic_stylesheet
|
||||
|
||||
@ -245,7 +244,7 @@ def run_report(dbstate, uistate, category, handle, pdata, container=None,
|
||||
d = TextBufDoc(make_basic_stylesheet(), None)
|
||||
d.dbstate = dbstate
|
||||
d.uistate = uistate
|
||||
if isinstance(handle, STRTYPE): # a handle
|
||||
if isinstance(handle, str): # a handle
|
||||
if category == CATEGORY_QR_PERSON :
|
||||
obj = dbstate.db.get_person_from_handle(handle)
|
||||
elif category == CATEGORY_QR_FAMILY :
|
||||
|
@ -55,7 +55,6 @@ from gramps.gen.lib.urltype import UrlType
|
||||
from gramps.gen.lib.eventtype import EventType
|
||||
from gramps.gen.display.name import displayer as _nd
|
||||
from gramps.gen.plug.utils import OpenFileOrStdout
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -91,7 +90,7 @@ class VCardWriter(object):
|
||||
@staticmethod
|
||||
def esc(data):
|
||||
"""Escape the special chars of the VCard protocol."""
|
||||
if isinstance(data, STRTYPE):
|
||||
if isinstance(data, str):
|
||||
for char in VCardWriter.TOBE_ESCAPED:
|
||||
data = data.replace(char, VCardWriter.ESCAPE_CHAR + char)
|
||||
return data
|
||||
|
@ -56,7 +56,7 @@ from gramps.gen.datehandler import parser as _dp
|
||||
from gramps.gen.utils.string import gender as gender_map
|
||||
from gramps.gen.utils.id import create_id
|
||||
from gramps.gen.lib.eventroletype import EventRoleType
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode, STRTYPE
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.display.place import displayer as place_displayer
|
||||
|
||||
|
@ -50,7 +50,6 @@ import imp
|
||||
imp.reload(module)
|
||||
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -95,7 +94,7 @@ def importData(database, filename, user):
|
||||
else:
|
||||
code_set = ""
|
||||
|
||||
assert(isinstance(code_set, STRTYPE))
|
||||
assert(isinstance(code_set, str))
|
||||
|
||||
try:
|
||||
ifile = open(filename, "rb")
|
||||
|
@ -52,7 +52,7 @@ from gramps.gen.lib import (Attribute, AttributeType, ChildRef, Citation,
|
||||
Family, FamilyRelType, Name, NameType, Note, Person, PersonRef,
|
||||
Place, Source)
|
||||
from gramps.gen.db import DbTxn
|
||||
from gramps.gen.constfunc import STRTYPE, cuni, conv_to_unicode
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode
|
||||
from html.entities import name2codepoint
|
||||
|
||||
_date_parse = re.compile('([kmes~?<>]+)?([0-9/]+)([J|H|F])?(\.\.)?([0-9/]+)?([J|H|F])?')
|
||||
|
@ -132,7 +132,7 @@ from gramps.gen.db.dbconst import EVENT_KEY
|
||||
from gramps.gui.dialog import WarningDialog
|
||||
from gramps.gen.lib.const import IDENTICAL, DIFFERENT
|
||||
from gramps.gen.lib import (StyledText, StyledTextTag, StyledTextTagType)
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode, STRTYPE, UNITYPE, win
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode, UNITYPE, win
|
||||
from gramps.plugins.lib.libplaceimport import PlaceImport
|
||||
from gramps.gen.display.place import displayer as place_displayer
|
||||
|
||||
@ -7440,7 +7440,7 @@ class GedcomParser(UpdateCallback):
|
||||
pass
|
||||
|
||||
def build_media_object(self, obj, form, filename, title, note):
|
||||
if isinstance(form, STRTYPE) and form.lower() == "url":
|
||||
if isinstance(form, str) and form.lower() == "url":
|
||||
url = Url()
|
||||
url.set_path(filename)
|
||||
url.set_description(title)
|
||||
@ -7722,7 +7722,7 @@ class GedcomStageOne(object):
|
||||
elif key in ("CHIL", "CHILD") and self.__is_xref_value(value):
|
||||
self.famc[value[1:-1]].append(current_family_id)
|
||||
elif key == 'CHAR' and not self.enc:
|
||||
assert(isinstance(value, STRTYPE))
|
||||
assert(isinstance(value, str))
|
||||
self.enc = value
|
||||
|
||||
def get_famc_map(self):
|
||||
@ -7747,7 +7747,7 @@ class GedcomStageOne(object):
|
||||
"""
|
||||
Forces the encoding
|
||||
"""
|
||||
assert(isinstance(enc, STRTYPE))
|
||||
assert(isinstance(enc, str))
|
||||
self.enc = enc
|
||||
|
||||
def get_person_count(self):
|
||||
|
@ -36,7 +36,6 @@ import os
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.const import PLUGINS_DIR, USER_PLUGINS
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
from gramps.gen.lib.gcalendar import (gregorian_ymd, hebrew_sdn)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -458,7 +457,7 @@ class _Holidays:
|
||||
if isinstance(offset, int):
|
||||
if offset != 0:
|
||||
ndate = ndate.fromordinal(ndate.toordinal() + offset)
|
||||
elif isinstance(offset, STRTYPE):
|
||||
elif isinstance(offset, str):
|
||||
direction = 1
|
||||
if offset[0] == "-":
|
||||
direction = -1
|
||||
|
@ -38,7 +38,7 @@ import re
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.constfunc import STRTYPE, cuni
|
||||
from gramps.gen.constfunc import cuni
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -322,7 +322,7 @@ class Html(list):
|
||||
:returns: reference to object with new value added
|
||||
"""
|
||||
if (isinstance(value, Html) or not hasattr(value, '__iter__') or
|
||||
isinstance(value, STRTYPE)):
|
||||
isinstance(value, str)):
|
||||
value = [value]
|
||||
index = len(self) - (1 if self.close else 0)
|
||||
self[index:index] = value
|
||||
@ -546,7 +546,7 @@ class Html(list):
|
||||
if len(self) < 2:
|
||||
raise AttributeError('No closing tag. Cannot set inside value')
|
||||
if (isinstance(value, Html) or not hasattr(value, '__iter__') or
|
||||
isinstance(value, STRTYPE)):
|
||||
isinstance(value, str)):
|
||||
value = [value]
|
||||
self[1:-1] = value
|
||||
#
|
||||
|
@ -40,7 +40,7 @@ Mary Smith was born on 3/28/1923.
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.lib import EventType, PlaceType, Location
|
||||
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||
from gramps.gen.constfunc import STRTYPE, cuni
|
||||
from gramps.gen.constfunc import cuni
|
||||
from gramps.gen.utils.location import get_main_location
|
||||
from gramps.gen.display.place import displayer as place_displayer
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
@ -38,7 +38,6 @@ Italian-Specific classes for relationships.
|
||||
|
||||
from gramps.gen.lib import Person
|
||||
import gramps.gen.relationship
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -337,7 +336,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
||||
(secondRel, firstRel, common) = \
|
||||
self.get_relationship_distance(db, orig_person, other_person)
|
||||
|
||||
if isinstance(common, STRTYPE):
|
||||
if isinstance(common, str):
|
||||
return (common, [])
|
||||
elif common:
|
||||
person_handle = common[0]
|
||||
|
@ -67,7 +67,7 @@ from gramps.gen.const import CUSTOM_FILTERS
|
||||
from gramps.gen.constfunc import is_quartz, win
|
||||
from gramps.gui.dialog import RunDatabaseRepair, ErrorDialog
|
||||
from gramps.gui.utils import color_graph_box, hex_to_rgb_float, is_right_click
|
||||
from gramps.gen.constfunc import STRTYPE, lin
|
||||
from gramps.gen.constfunc import lin
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
|
@ -42,7 +42,6 @@ from gramps.gen.db import (PERSON_KEY,
|
||||
REPOSITORY_KEY,
|
||||
NOTE_KEY)
|
||||
from gramps.gen.utils.id import create_id
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
from gramps.webapp.libdjango import DjangoInterface
|
||||
from django.db import transaction
|
||||
|
||||
@ -341,7 +340,7 @@ class DbDjango(DbWriteBase, DbReadBase):
|
||||
|
||||
@staticmethod
|
||||
def _validated_id_prefix(val, default):
|
||||
if isinstance(val, STRTYPE) and val:
|
||||
if isinstance(val, str) and val:
|
||||
try:
|
||||
str_ = val % 1
|
||||
except TypeError: # missing conversion specifier
|
||||
|
@ -64,7 +64,6 @@ from gramps.gen.lib import Person
|
||||
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||
from gramps.gen.plug import BasePluginManager
|
||||
from gramps.cli.grampscli import CLIManager
|
||||
from gramps.gen.constfunc import STRTYPE
|
||||
from gramps.gen.utils.grampslocale import GrampsLocale
|
||||
|
||||
#FIXME: A locale should be obtained from the user and used to
|
||||
@ -277,9 +276,9 @@ def make_button(text, url, *args):
|
||||
kwargs = cuni("")
|
||||
last = cuni("")
|
||||
for arg in args:
|
||||
if isinstance(arg, STRTYPE) and arg.startswith("?"):
|
||||
if isinstance(arg, str) and arg.startswith("?"):
|
||||
kwargs = arg
|
||||
elif isinstance(arg, STRTYPE) and arg.startswith("#"):
|
||||
elif isinstance(arg, str) and arg.startswith("#"):
|
||||
last = arg
|
||||
elif arg == "":
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user