1
- """Module for custom click types regarding to ansible"""
1
+ """Module for custom click types regarding to ansible. """
2
2
3
3
import click
4
4
import os
@@ -64,7 +64,7 @@ def convert(self, value, param, ctx):
64
64
data = self .v .load (open (self .vault ).read ())
65
65
except AnsibleError as e :
66
66
if 'not vault encrypted data' in str (e ):
67
- data = yaml .load (open (self .vault ).read (), SafeLoader ) or {}
67
+ data = yaml .safe_load (open (self .vault ).read (), SafeLoader ) or {}
68
68
except Exception as e :
69
69
self .fail ('Decryption failed: {0}' .format (str (e )), param , ctx )
70
70
@@ -74,26 +74,26 @@ def convert(self, value, param, ctx):
74
74
75
75
try :
76
76
self .v .dump (data , open (self .vault , 'w' ))
77
- except : # noqa: E722
77
+ except Exception :
78
78
self .fail ('Error while encrypting data' , param , ctx )
79
79
80
80
return self .path
81
81
82
- def _populate_data (self , input = {} , keys = [] , value = None ):
82
+ def _populate_data (self , origin : dict = None , keys : list = None , value : str = None ):
83
83
"""Save value at the desired position in vault.
84
84
85
85
This method takes vault data, a list of keys where to store the value.
86
86
87
- :param input : The dictionary of vault data, defaults to {}
88
- :type input : dict, optional
87
+ :param origin : The dictionary of vault data, defaults to {}
88
+ :type origin : dict, optional
89
89
:param keys: List of keys that describe the desired position in vault, defaults to []
90
90
:type keys: list, optional
91
91
:param value: The value to store in vault, defaults to None
92
92
:type value: str, optional
93
93
:return: The vault data extended by `value` at the desired position.
94
94
:rtype: dict
95
95
"""
96
- data = input .copy ()
96
+ data = origin .copy ()
97
97
98
98
if keys :
99
99
key = keys [0 ]
0 commit comments