Skip to content

Commit 235a85e

Browse files
committed
Removing properties in favor of docstrings. Renaming needs_force_delete to maybe_used.
1 parent 1a1de4f commit 235a85e

File tree

1 file changed

+35
-121
lines changed

1 file changed

+35
-121
lines changed

dataikuapi/dss/plugin.py

Lines changed: 35 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -183,141 +183,73 @@ def put_file(self, path, f):
183183
class DSSPluginUsage(object):
184184
"""
185185
Information on a usage of an element of a plugin.
186+
187+
Has the following properties:
188+
- element_kind: webapps, python-formats,...
189+
- element_type: type name of the element
190+
- object_id: id of the object using the plugin element. Can be None.
191+
- object_type: type of the object using the plugin element. Can be None.
192+
- project_key: project key of the object using the plugin element. Can be None.
186193
"""
187194
def __init__(self, data):
188195
"""
189196
Instantiate a DSSPluginUsage from the dict of its properties.
190197
:param dict data: dict of properties
191198
"""
192-
self._data = data
193-
194-
def get_raw(self):
195-
"""
196-
Get plugin usage as a dictionary
197-
:rtype: dict
198-
"""
199-
return self._data
200-
201-
@property
202-
def element_kind(self):
203-
"""
204-
Element kind (webapps, python-formats,...)
205-
:return: the element kind
206-
:rtype: str
207-
"""
208-
return self._data["elementKind"]
209-
210-
@property
211-
def element_type(self):
212-
"""
213-
Element type
214-
:return: the element type
215-
:rtype: str
216-
"""
217-
return self._data["elementType"]
218-
219-
@property
220-
def object_id(self):
221-
"""
222-
:return: Id of the object using the plugin element
223-
:rtype: str or none
224-
"""
225-
return self._data.get("objectId", None)
226-
227-
@property
228-
def object_type(self):
229-
"""
230-
:return: Type of the object using the plugin element
231-
:rtype: str or none
232-
"""
233-
return self._data.get("objectType", None)
234-
235-
@property
236-
def project_key(self):
237-
"""
238-
:return: Project key of the object using the plugin element
239-
:rtype: str or none
240-
"""
241-
return self._data.get("projectKey", None)
199+
self.element_kind = data["elementKind"]
200+
self.element_type = data["elementType"]
201+
self.object_id = data.get("objectId", None)
202+
self.object_type = data.get("objectType", None)
203+
self.project_key = data.get("projectKey", None)
242204

243205

244206
class DSSMissingType(object):
245207
"""
246208
Information on a type not found while analyzing usages of a plugin.
209+
210+
Has the following properties:
211+
- missing type: the missing type
212+
- object_id: id of the object depending on the missing type. Can be None.
213+
- object_type: type of the object depending on the missing type. Can be None.
214+
- project_key: project key of the object depending on the missing type. Can be None.
215+
247216
"""
248217
def __init__(self, data):
249218
"""
250219
Instantiate a DSSMissingType from the dict of its properties
251220
:param dict data: dictionary of properties
252221
"""
253-
self._data = data
254-
255-
def get_raw(self):
256-
"""
257-
Get missing type as a dictionary
258-
:rtype: dict
259-
"""
260-
return self._data
261-
262-
@property
263-
def missing_type(self):
264-
"""
265-
:return: the missing type
266-
:rtype: str
267-
"""
268-
return self._data["missingType"]
269-
270-
@property
271-
def object_id(self):
272-
"""
273-
:return: Id of the object depending on the missing type
274-
:rtype: str or none
275-
"""
276-
return self._data.get("objectId", None)
277-
278-
@property
279-
def object_type(self):
280-
"""
281-
:return: Type of the object depending on the missing type
282-
:rtype: str or none
283-
"""
284-
return self._data.get("objectType", None)
285-
286-
@property
287-
def project_key(self):
288-
"""
289-
:return: Project key of the object depending on the missing type
290-
:rtype: str or none
291-
"""
292-
return self._data.get("projectKey", None)
222+
self.missing_type = data["missingType"]
223+
self.object_id = data.get("objectId", None)
224+
self.object_type = data.get("objectType", None)
225+
self.project_key = data.get("projectKey", None)
293226

294227

295228
class DSSPluginUsages(object):
296229
"""
297230
Information on the usages of a plugin.
298231
299-
Contains both usages (a list of :class:`DSSPluginUsage`) and analysis errors, if any
300-
(a list of :class:`DSSMissingType`).
232+
Has the following properties:
233+
- usages (list of :class:`DSSPluginUsage`)
234+
- missing_types (a list of :class:`DSSMissingType`).
301235
302236
Some custom types may not be found during usage analysis, typically when a plugin was removed
303237
but is still used. This prevents some detailed analysis and may hide some uses.
304-
This information is provided in missingTypes.
238+
This information is provided in missing_types.
305239
"""
306240
def __init__(self, data):
307241
"""
308242
Initialize a DSSPluginUsages from a dict of its properties
309243
310244
:param dict data: the usages as json dict
311-
:param list(:class:`DSSPluginUsage`) usages: plugin usages
312-
:param list(:class:`DSSMissingType`) missing_types:
313245
"""
314246
self._data = data
315-
self._usages = []
316-
self._missing_types = []
247+
self.usages = []
248+
self.missing_types = []
317249
for json_usage in data.get("usages", []):
318-
self._usages.append(DSSPluginUsage(json_usage))
250+
self.usages.append(DSSPluginUsage(json_usage))
319251
for json_missing_type in data.get("missingTypes"):
320-
self._missing_types.append(DSSMissingType(json_missing_type))
252+
self.missing_types.append(DSSMissingType(json_missing_type))
321253

322254
def get_raw(self):
323255
"""
@@ -326,28 +258,10 @@ def get_raw(self):
326258
"""
327259
return self._data
328260

329-
def needs_force_delete(self):
261+
def maybe_used(self):
330262
"""
331-
Returns true the deletion of the plugin should be forced, as usages of the plugin were found, or errors
332-
encoutered during analysis.
263+
Returns true if the plugin maybe in use, as usages of the plugin were found, or errors
264+
encountered during analysis.
333265
:return:
334266
"""
335-
return not (not self._usages and not self._missing_types)
336-
337-
@property
338-
def usages(self):
339-
"""
340-
List of plugin usages
341-
:return: plugin usages
342-
:rtype: list(:class:`DSSPluginUsage`)
343-
"""
344-
return self._usages
345-
346-
@property
347-
def missing_types(self):
348-
"""
349-
List of missing types
350-
:return: missing types
351-
:rtype: list(:class:`DSSMissingType` )
352-
"""
353-
return self._missing_types
267+
return not (not self.usages and not self.missing_types)

0 commit comments

Comments
 (0)