Fix PythonDeprecationWarning for collections.abc

This commit is contained in:
prculley 2019-02-13 08:25:44 -06:00 committed by Nick Hall
parent c82ec4c65b
commit 0213e65ff0
11 changed files with 27 additions and 26 deletions

View File

@ -27,7 +27,7 @@
#-------------------------------------------------------------------------
from xml.sax import make_parser, SAXParseException
import os
import collections
from collections import abc
#-------------------------------------------------------------------------
#
@ -78,7 +78,7 @@ class FilterList:
plugin_filters = []
try:
for plug in plugins:
if isinstance(plug, collections.Callable):
if isinstance(plug, abc.Callable):
plug = plug(namespace)
if plug:
if isinstance(plug, (list, tuple)):

View File

@ -32,7 +32,7 @@ other Gramps baggage.
#
#-------------------------------------------------------------------------
import time
import collections
from collections import abc
import logging
_LOG = logging.getLogger(".gen")
@ -54,7 +54,7 @@ class UpdateCallback:
:param interval: number of seconds at most between the updates
:type interval: int
"""
if isinstance(callback, collections.Callable):
if isinstance(callback, abc.Callable):
# callback is really callable
self.update = self.update_real
self.callback = callback

View File

@ -31,7 +31,7 @@
import random
import os
from xml.sax.saxutils import escape
import collections
from collections import abc
#-------------------------------------------------------------------------
#
@ -201,7 +201,7 @@ class ConfigureDialog(ManagedWindow):
"""
This method builds the notebook pages in the panel
"""
if isinstance(configure_page_funcs, collections.Callable):
if isinstance(configure_page_funcs, abc.Callable):
pages = configure_page_funcs()
else:
pages = configure_page_funcs

View File

@ -25,7 +25,7 @@ from gramps.gen.filters import (rules, FilterList, GenericFilterFactory,
reload_custom_filters)
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
import collections
from collections import abc
def make_filter(dbstate, uistate, objclass, gramps_ids, title=None):
"""
@ -39,7 +39,7 @@ def make_filter(dbstate, uistate, objclass, gramps_ids, title=None):
filter = FilterClass()
if title is None:
title = _("Filter %s from Clipboard") % objclass
if isinstance(title, collections.Callable):
if isinstance(title, abc.Callable):
title = title()
filter.set_name(title)
struct_time = time.localtime()

View File

@ -39,7 +39,7 @@ from io import StringIO
#
#------------------------------------------------------------------------
import logging
import collections
from collections import abc
log = logging.getLogger(".quickreports")
#-------------------------------------------------------------------------
@ -105,9 +105,9 @@ def create_web_connect_menu(dbstate, uistate, nav_group, handle, prefix):
pmgr = GuiPluginManager.get_instance()
plugins = pmgr.process_plugin_data('WebConnect')
try:
connections = [plug(nav_group) if isinstance(plug, collections.Callable) else plug
for plug in plugins]
except:
connections = [plug(nav_group) if isinstance(plug, abc.Callable) else
plug for plug in plugins]
except BaseException:
import traceback
traceback.print_exc()
connections = []

View File

@ -43,7 +43,7 @@ import codecs
#
#------------------------------------------------------------------------
import logging
import collections
from collections import abc
LOG = logging.getLogger(".ExportCSV")
#-------------------------------------------------------------------------
@ -173,7 +173,7 @@ class CSVWriter:
self.option_box = option_box
self.filename = filename
self.user = user
if isinstance(self.user.callback, collections.Callable): # callback is really callable
if isinstance(self.user.callback, abc.Callable): # is really callable
self.update = self.update_real
else:
self.update = self.update_empty

View File

@ -34,7 +34,7 @@
#
#------------------------------------------------------------------------
import logging
import collections
from collections import abc
log = logging.getLogger(".WriteFtree")
#-------------------------------------------------------------------------
@ -73,7 +73,7 @@ class FtreeWriter:
self.user = user
self.option_box = option_box
# is callback is really callable?
if isinstance(self.user.callback, collections.Callable):
if isinstance(self.user.callback, abc.Callable):
self.update = self.update_real
else:
self.update = self.update_empty

View File

@ -37,7 +37,7 @@ import os
#
#------------------------------------------------------------------------
import logging
import collections
from collections import abc
log = logging.getLogger(".WriteGeneWeb")
#-------------------------------------------------------------------------
@ -60,7 +60,7 @@ class GeneWebWriter:
self.filename = filename
self.user = user
self.option_box = option_box
if isinstance(self.user.callback, collections.Callable): # callback is really callable
if isinstance(self.user.callback, abc.Callable): # is really callable
self.update = self.update_real
else:
self.update = self.update_empty

View File

@ -38,7 +38,7 @@ from time import localtime
#
#------------------------------------------------------------------------
import logging
import collections
from collections import abc
log = logging.getLogger(".ExportVCal")
#-------------------------------------------------------------------------
@ -61,7 +61,7 @@ class CalendarWriter:
self.filename = filename
self.user = user
self.option_box = option_box
if isinstance(self.user.callback, collections.Callable): # callback is really callable
if isinstance(self.user.callback, abc.Callable): # is really callable
self.update = self.update_real
else:
self.update = self.update_empty

View File

@ -38,7 +38,7 @@ from textwrap import TextWrapper
#
#------------------------------------------------------------------------
import logging
import collections
from collections import abc
log = logging.getLogger(".ExportVCard")
#-------------------------------------------------------------------------
@ -109,7 +109,7 @@ class VCardWriter:
self.user = user
self.filehandle = None
self.option_box = option_box
if isinstance(self.user.callback, collections.Callable): # callback is really callable
if isinstance(self.user.callback, abc.Callable): # is really callable
self.update = self.update_real
else:
self.update = self.update_empty

View File

@ -38,7 +38,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import re
import logging
import collections
from collections import abc
LOG = logging.getLogger(".ImportXML")
#-------------------------------------------------------------------------
@ -737,7 +737,7 @@ class GrampsParser(UpdateCallback):
if (orig_handle in self.import_handles and
target in self.import_handles[orig_handle]):
handle = self.import_handles[handle][target][HANDLE]
if not isinstance(prim_obj, collections.Callable):
if not isinstance(prim_obj, abc.Callable):
# This method is called by a start_<primary_object> method.
get_raw_obj_data = {"person": self.db.get_raw_person_data,
"family": self.db.get_raw_family_data,
@ -780,7 +780,8 @@ class GrampsParser(UpdateCallback):
while has_handle_func(handle):
handle = create_id()
self.import_handles[orig_handle] = {target: [handle, False]}
if isinstance(prim_obj, collections.Callable): # method is called by a reference
# method is called by a reference
if isinstance(prim_obj, abc.Callable):
prim_obj = prim_obj()
else:
self.import_handles[orig_handle][target][INSTANTIATED] = True
@ -874,7 +875,7 @@ class GrampsParser(UpdateCallback):
handle = create_id()
while has_handle_func(handle):
handle = create_id()
if isinstance(prim_obj, collections.Callable):
if isinstance(prim_obj, abc.Callable):
prim_obj = prim_obj()
prim_obj.set_handle(handle)
prim_obj.set_gramps_id(gramps_id)