Merge "Replace deprecated import of ABCs from collections"
This commit is contained in:
commit
1ff618a519
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
"""I totally stole most of this from melange, thx guys!!!"""
|
"""I totally stole most of this from melange, thx guys!!!"""
|
||||||
|
|
||||||
import collections
|
from collections import abc
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -331,7 +331,7 @@ def unpack_singleton(container):
|
|||||||
def is_collection(item):
|
def is_collection(item):
|
||||||
"""Return True is a given item is an iterable collection, but not a string.
|
"""Return True is a given item is an iterable collection, but not a string.
|
||||||
"""
|
"""
|
||||||
return (isinstance(item, collections.Iterable) and
|
return (isinstance(item, abc.Iterable) and
|
||||||
not isinstance(item, (bytes, str)))
|
not isinstance(item, (bytes, str)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import collections
|
from collections import abc
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ def update_dict(updates, target):
|
|||||||
|
|
||||||
if updates is not None:
|
if updates is not None:
|
||||||
for k, v in updates.items():
|
for k, v in updates.items():
|
||||||
if isinstance(v, collections.Mapping):
|
if isinstance(v, abc.Mapping):
|
||||||
target[k] = update_dict(v, target.get(k, {}))
|
target[k] = update_dict(v, target.get(k, {}))
|
||||||
else:
|
else:
|
||||||
target[k] = updates[k]
|
target[k] = updates[k]
|
||||||
@ -84,7 +84,7 @@ def flatten_dict(target, namespace_sep='.'):
|
|||||||
"""
|
"""
|
||||||
def flatten(target, keys, namespace_sep):
|
def flatten(target, keys, namespace_sep):
|
||||||
flattened = {}
|
flattened = {}
|
||||||
if isinstance(target, collections.Mapping):
|
if isinstance(target, abc.Mapping):
|
||||||
for k, v in target.items():
|
for k, v in target.items():
|
||||||
flattened.update(
|
flattened.update(
|
||||||
flatten(v, keys + [k], namespace_sep))
|
flatten(v, keys + [k], namespace_sep))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user