19
19
# DEALINGS IN THE SOFTWARE.
20
20
"""Base Driver Module."""
21
21
22
- import abc
23
22
import inspect
24
23
import os
24
+ from abc import ABCMeta , abstractmethod
25
25
26
26
import pkg_resources
27
27
32
32
class Driver (object ):
33
33
"""Driver Class."""
34
34
35
- __metaclass__ = abc . ABCMeta
35
+ __metaclass__ = ABCMeta
36
36
37
37
def __init__ (self , config = None ):
38
38
"""
@@ -43,20 +43,19 @@ def __init__(self, config=None):
43
43
"""
44
44
self ._config = config
45
45
self ._path = os .path .abspath (os .path .dirname (inspect .getfile (self .__class__ )))
46
- self .module = self .__module__ .split ("." )[0 ]
46
+ self .module = self .__module__ .split ("." , maxsplit = 1 )[0 ]
47
47
self .version = pkg_resources .get_distribution (self .module ).version
48
48
49
- @property # type: ignore
50
- @abc . abstractmethod
51
- def name (self ): # pragma: no cover
49
+ @property
50
+ @abstractmethod
51
+ def name (self ) -> str : # pragma: no cover
52
52
"""
53
53
Name of the driver and returns a string.
54
54
55
55
:returns: str
56
56
"""
57
57
58
58
@name .setter # type: ignore
59
- @abc .abstractmethod
60
59
def name (self , value ): # pragma: no cover
61
60
"""
62
61
Driver name setter and returns None.
@@ -76,7 +75,8 @@ def testinfra_options(self):
76
75
"ansible-inventory" : self ._config .provisioner .inventory_directory ,
77
76
}
78
77
79
- @abc .abstractproperty
78
+ @property
79
+ @abstractmethod
80
80
def login_cmd_template (self ): # pragma: no cover
81
81
"""
82
82
Get the login command template to be populated by ``login_options`` as \
@@ -85,23 +85,25 @@ def login_cmd_template(self): # pragma: no cover
85
85
:returns: str
86
86
"""
87
87
88
- @abc .abstractproperty
88
+ @property
89
+ @abstractmethod
89
90
def default_ssh_connection_options (self ): # pragma: no cover
90
91
"""
91
92
SSH client options and returns a list.
92
93
93
94
:returns: list
94
95
"""
95
96
96
- @abc .abstractproperty
97
+ @property
98
+ @abstractmethod
97
99
def default_safe_files (self ): # pragma: no cover
98
100
"""
99
101
Generate files to be preserved.
100
102
101
103
:returns: list
102
104
"""
103
105
104
- @abc . abstractmethod
106
+ @abstractmethod
105
107
def login_options (self , instance_name ): # pragma: no cover
106
108
"""
107
109
Options used in the login command and returns a dict.
@@ -110,7 +112,7 @@ def login_options(self, instance_name): # pragma: no cover
110
112
:returns: dict
111
113
"""
112
114
113
- @abc . abstractmethod
115
+ @abstractmethod
114
116
def ansible_connection_options (self , instance_name ): # pragma: no cover
115
117
"""
116
118
Ansible specific connection options supplied to inventory and returns a \
@@ -120,7 +122,7 @@ def ansible_connection_options(self, instance_name): # pragma: no cover
120
122
:returns: dict
121
123
"""
122
124
123
- @abc . abstractmethod
125
+ @abstractmethod
124
126
def sanity_checks (self ):
125
127
"""
126
128
Confirm that driver is usable.
0 commit comments