|
20 | 20 |
|
21 | 21 | from .exceptions import ObjectAlreadyExists |
22 | 22 | from .utils import intersection, OrderedDefaultDict |
| 23 | +from .enum import DiffSyncActions |
23 | 24 |
|
24 | 25 |
|
25 | 26 | class Diff: |
@@ -105,9 +106,9 @@ def order_children_default(cls, children: Mapping) -> Iterator["DiffElement"]: |
105 | 106 | def summary(self) -> Mapping[Text, int]: |
106 | 107 | """Build a dict summary of this Diff and its child DiffElements.""" |
107 | 108 | summary = { |
108 | | - "create": 0, |
109 | | - "update": 0, |
110 | | - "delete": 0, |
| 109 | + DiffSyncActions.CREATE: 0, |
| 110 | + DiffSyncActions.UPDATE: 0, |
| 111 | + DiffSyncActions.DELETE: 0, |
111 | 112 | "no-change": 0, |
112 | 113 | } |
113 | 114 | for child in self.get_children(): |
@@ -224,18 +225,18 @@ def action(self) -> Optional[Text]: |
224 | 225 | """Action, if any, that should be taken to remediate the diffs described by this element. |
225 | 226 |
|
226 | 227 | Returns: |
227 | | - str: "create", "update", "delete", or None |
| 228 | + str: DiffSyncActions ("create", "update", "delete", or None) |
228 | 229 | """ |
229 | 230 | if self.source_attrs is not None and self.dest_attrs is None: |
230 | | - return "create" |
| 231 | + return DiffSyncActions.CREATE |
231 | 232 | if self.source_attrs is None and self.dest_attrs is not None: |
232 | | - return "delete" |
| 233 | + return DiffSyncActions.DELETE |
233 | 234 | if ( |
234 | 235 | self.source_attrs is not None |
235 | 236 | and self.dest_attrs is not None |
236 | 237 | and any(self.source_attrs[attr_key] != self.dest_attrs[attr_key] for attr_key in self.get_attrs_keys()) |
237 | 238 | ): |
238 | | - return "update" |
| 239 | + return DiffSyncActions.UPDATE |
239 | 240 |
|
240 | 241 | return None |
241 | 242 |
|
@@ -328,9 +329,9 @@ def has_diffs(self, include_children: bool = True) -> bool: |
328 | 329 | def summary(self) -> Mapping[Text, int]: |
329 | 330 | """Build a summary of this DiffElement and its children.""" |
330 | 331 | summary = { |
331 | | - "create": 0, |
332 | | - "update": 0, |
333 | | - "delete": 0, |
| 332 | + DiffSyncActions.CREATE: 0, |
| 333 | + DiffSyncActions.UPDATE: 0, |
| 334 | + DiffSyncActions.DELETE: 0, |
334 | 335 | "no-change": 0, |
335 | 336 | } |
336 | 337 | if self.action: |
|
0 commit comments