Issues (10)

pystratum_common/wrapper/BulkWrapper.py (1 issue)

1
import re
2
from abc import ABC
3
from typing import Any, Dict
4
5
from pystratum_common.wrapper.Wrapper import Wrapper
6
7
8 View Code Duplication
class BulkWrapper(Wrapper, ABC):
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
9
    """
10
    Wrapper method generator for stored procedures with designation type bulk.
11
    """
12
13
    # ------------------------------------------------------------------------------------------------------------------
14
    def _return_type_hint(self) -> str:
15
        """
16
        Returns the return type hint of the wrapper method.
17
18
        :rtype: str
19
        """
20
        return 'int'
21
22
    # ------------------------------------------------------------------------------------------------------------------
23
    def _get_docstring_return_type(self) -> str:
24
        """
25
        Returns the return type of the wrapper methods the be used in the docstring.
26
27
        :rtype: str
28
        """
29
        return 'int'
30
31
    # ------------------------------------------------------------------------------------------------------------------
32
    @staticmethod
33
    def _get_wrapper_args(routine: Dict[str, Any]) -> str:
34
        """
35
        Returns code for the parameters of the wrapper method for the stored routine.
36
37
        :param dict[str,*] routine: The routine metadata.
38
39
        :rtype: str
40
        """
41
        parameters = Wrapper._get_wrapper_args(routine)
42
43
        return re.sub(r'^self', 'self, bulk_handler', parameters)
44
45
    # ------------------------------------------------------------------------------------------------------------------
46
    def _write_docstring_parameters(self, routine: Dict[str, Any]) -> None:
47
        """
48
        Writes the parameters part of the docstring for the wrapper method of a stored routine.
49
50
        :param dict routine: The metadata of the stored routine.
51
        """
52
        self._write_line('')
53
        self._write_line(':param pystratum.BulkHandler.BulkHandler bulk_handler: '
54
                         'The bulk handler for processing the selected rows.')
55
56
        Wrapper._write_docstring_parameters(self, routine)
57
58
# ----------------------------------------------------------------------------------------------------------------------
59