]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Correct usage of collections.abc 25318/head
authorJames Page <james.page@ubuntu.com>
Thu, 29 Nov 2018 09:47:07 +0000 (09:47 +0000)
committerJames Page <james.page@ubuntu.com>
Thu, 29 Nov 2018 09:48:43 +0000 (09:48 +0000)
Some classes should still be imported directly from collections;
only OrderedDict, Iterable and Callable (in the context of the
ceph codebase) are found in collections.abc.

The current code works due to the fallback support for Python 2.

Signed-off-by: James Page <james.page@ubuntu.com>
16 files changed:
qa/tasks/cephfs/test_data_scan.py
qa/tasks/cephfs/test_forward_scrub.py
qa/tasks/cephfs/test_recovery_pool.py
qa/tasks/cephfs/test_scrub.py
qa/tasks/mgr/dashboard/helper.py
qa/tasks/vstart_runner.py
src/ceph-volume/ceph_volume/__init__.py
src/pybind/cephfs/cephfs.pyx
src/pybind/mgr/dashboard/controllers/cephfs.py
src/pybind/mgr/dashboard/services/ceph_service.py
src/pybind/mgr/mgr_module.py
src/pybind/mgr/restful/api/crush.py
src/pybind/mgr/status/module.py
src/pybind/mgr/telemetry/module.py
src/pybind/rgw/rgw.pyx
src/tools/rgw/parse-cr-dump.py

index 478d2a12a652f50e3a04d737308f8cff4a015363..0faeb43fc03f3df631105464ee84f2c3b7d86f2e 100644 (file)
@@ -8,10 +8,7 @@ import logging
 import os
 from textwrap import dedent
 import traceback
-try:
-    from collections.abc import namedtuple, defaultdict
-except ImportError:
-    from collections import namedtuple, defaultdict
+from collections import namedtuple, defaultdict
 
 from teuthology.orchestra.run import CommandFailedError
 from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology
index 6150dbaea4a1642437d4f13fca6acccd967c12c3..e165780f31f188641fd527474e7155482bc14c6a 100644 (file)
@@ -10,10 +10,7 @@ how the functionality responds to damaged metadata.
 import json
 
 import logging
-try:
-    from collections.abc import namedtuple
-except ImportError:
-    from collections import namedtuple
+from collections import namedtuple
 from textwrap import dedent
 
 from teuthology.orchestra.run import CommandFailedError
index 41fd512f1188726ff9fd13f7a14086498c87bc65..97049b9c0a3374af448c708d1d34370380f3a8ab 100644 (file)
@@ -8,10 +8,7 @@ import logging
 import os
 from textwrap import dedent
 import traceback
-try:
-    from collections.abc import namedtuple, defaultdict
-except ImportError:
-    from collections import namedtuple, defaultdict
+from collections import namedtuple, defaultdict
 
 from teuthology.orchestra.run import CommandFailedError
 from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology
index 4cc4f7f0c94b0444d416598d3b94f179c2b1659a..9469dfce6e4939edd926890eda96b8f43465cb0a 100644 (file)
@@ -4,10 +4,7 @@ Test CephFS scrub (distinct from OSD scrub) functionality
 import logging
 import os
 import traceback
-try:
-    from collections.abc import namedtuple
-except ImportError:
-    from collections import namedtuple
+from collections import namedtuple
 
 from teuthology.orchestra.run import CommandFailedError
 from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology
index 9b8444e62ccc806f16e6a83b462ceef45f85fb53..13fc8480b7a37fe8ea2143d309874e85d827e9a7 100644 (file)
@@ -4,10 +4,7 @@ from __future__ import absolute_import
 
 import json
 import logging
-try:
-    from collections.abc import namedtuple
-except ImportError:
-    from collections import namedtuple
+from collections import namedtuple
 import time
 
 import requests
index 8afafb59eebff4d3964ede432fe2367cf95a90a4..bf54af4921938ff11bdce3e3ca650bbb3cea29db 100644 (file)
@@ -26,10 +26,7 @@ Alternative usage:
 """
 
 from StringIO import StringIO
-try:
-    from collections.abc import defaultdict
-except ImportError:
-    from collections import defaultdict
+from collections import defaultdict
 import getpass
 import signal
 import tempfile
index fd997eea7089cf91839cd578d9949d9c2bf6ae24..640fb1e6fb1512bcf239c4c41dc2c2851335946e 100644 (file)
@@ -1,7 +1,4 @@
-try:
-    from collections.abc import namedtuple
-except ImportError:
-    from collections import namedtuple
+from collections import namedtuple
 
 
 sys_info = namedtuple('sys_info', ['devices'])
index 2fb748090cbab94836f310ce974c839b6e97583b..5f6ee6562b1fc366f41dde4365f6f253a4193016 100644 (file)
@@ -9,10 +9,7 @@ from libc.stdlib cimport malloc, realloc, free
 
 cimport rados
 
-try:
-    from collections.abc import namedtuple
-except ImportError:
-    from collections import namedtuple
+from collections import namedtuple
 from datetime import datetime
 import errno
 import os
index d481e493e7ec4e07db45666773cee89f79edc4be..df31d4a4f36eb2d9fb303c5167378159a24973fc 100644 (file)
@@ -1,10 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import absolute_import
 
-try:
-    from collections.abc import defaultdict
-except ImportError:
-    from collections import defaultdict
+from collections import defaultdict
 
 import cherrypy
 
index b0bec642a1a2ab7cc8206bae21727242e590796a..91b4f351ef6e7cd7d081753b18cfad05f5c265bc 100644 (file)
@@ -2,12 +2,8 @@
 from __future__ import absolute_import
 
 import time
-try:
-    import collections.abc
-    from collections.abc import defaultdict
-except ImportError:
-    import collections
-    from collections import defaultdict
+import collections
+from collections import defaultdict
 import json
 
 import rados
index 5d582039aedab1333acf650ab8f811276d16696f..fbdd3f1f420743157a8935a690546ff9f8d39c00 100644 (file)
@@ -5,10 +5,7 @@ import logging
 import json
 import six
 import threading
-try:
-    from collections.abc import defaultdict, namedtuple
-except ImportError:
-    from collections import defaultdict, namedtuple
+from collections import defaultdict, namedtuple
 import rados
 import time
 
index 6b2b3646cf9610048ab28a1516d5e5a5c6c24bc1..ee8589df0a41ae4abcdf307731b64481361c14e1 100644 (file)
@@ -2,10 +2,7 @@ from pecan import expose
 from pecan.rest import RestController
 
 from restful import common, context
-try:
-    from collections.abc import defaultdict
-except ImportError:
-    from collections import defaultdict
+from collections import defaultdict
 
 from restful.decorators import auth
 
index 7a4f72cb3cdb31130b53818d3541ded6144fb51d..99d3c7103d5bac22708fd66923d3be3e399fd4ff 100644 (file)
@@ -3,10 +3,7 @@
 High level status display commands
 """
 
-try:
-    from collections.abc import defaultdict
-except ImportError:
-    from collections import defaultdict
+from collections import defaultdict
 from prettytable import PrettyTable
 import errno
 import fnmatch
index d20b24979b55c701e6a7ff84a94e9e23a31201a3..f331e1825326b1725ac25d96d18ff627d5004b0e 100644 (file)
@@ -12,10 +12,7 @@ import uuid
 import time
 from datetime import datetime
 from threading import Event
-try:
-    from collections.abc import defaultdict
-except ImportError:
-    from collections import defaultdict
+from collections import defaultdict
 
 from mgr_module import MgrModule
 
index 39476aac86f87b6334d6349a169e1c269d867235..f512d33f84ab9ed80f86d5caa64067faf0134192 100644 (file)
@@ -10,10 +10,7 @@ from libc.stdlib cimport malloc, realloc, free
 
 cimport rados
 
-try:
-    from collections.abc import namedtuple
-except ImportError:
-    from collections import namedtuple
+from collections import namedtuple
 from datetime import datetime
 import errno
 
index e979cf33ec8fdd7984732e5d6c12e01bef1ad13b..539929b113d87aab22065e97fd8632d86d27c8ad 100755 (executable)
@@ -1,9 +1,6 @@
 #!/usr/bin/python
 from __future__ import print_function
-try:
-    from collections.abc import Counter
-except ImportError:
-    from collections import Counter
+from collections import Counter
 import argparse
 import json
 import re