def _cases_management(self, regex_number, matched_result):
        """
        A little internal helper of self.format. (Avoiding of nested loops)

        .. note::
            Please note that the second value of the case represent the groups
            in order :code:`[day,month,year]`.

            This means that a :code:`[2,1,0]` will be for example for a date
            in format :code:`2017-01-02` where
            :code:`01` is the month.

        :param regex_number: The identifiant of the regex.
        :type regex_number: int

        :param matched_result: The matched result to format.
        :type matched_result: list

        :return:
            A list representing the expiration date.
            The list can be "decoded" like :code:`[day, month, year]`
        :rtype: list|None
        """

        # We map our regex numbers with with the right group order.
        # Note: please report to the method note for more information about the mapping.
        cases = {
            "first": [[1, 2, 3, 10, 11, 22, 26, 27, 28, 29, 32, 34, 38], [0, 1, 2]],
            "second": [[14, 15, 31, 33, 36, 37], [1, 0, 2]],
            "third": [
                [4, 5, 6, 7, 8, 9, 12, 13, 16, 17, 18, 19, 20, 21, 23, 24, 25, 30, 35],
                [2, 1, 0],
            ],
        }

        for case in cases:
            # We loop through the cases.

            # We get the case data.
            case_data = cases[case]

            if int(regex_number) in case_data[0]:
                # The regex number is into the currently read case data.

                # We return a list with the formatted elements.
                # 1. We convert the day to 2 digits.
                # 2. We convert the month to the unified format.
                # 3. We return the year.
                return [
                    self._convert_1_to_2_digits(matched_result[case_data[1][0]]),
                    self._convert_or_shorten_month(matched_result[case_data[1][1]]),
                    str(matched_result[case_data[1][2]]),
                ]

        # The regex number is not already mapped.

        # We return the parsed data.
        return matched_result
def _cases_management(self, regex_number, matched_result):
        """
        A little internal helper of self.format. (Avoiding of nested loops)

        .. note::
            Please note that the second value of the case represent the groups
            in order :code:`[day,month,year]`.

            This means that a :code:`[2,1,0]` will be for example for a date
            in format :code:`2017-01-02` where
            :code:`01` is the month.

        :param regex_number: The identifiant of the regex.
        :type regex_number: int

        :param matched_result: The matched result to format.
        :type matched_result: list

        :return:
            A list representing the expiration date.
            The list can be "decoded" like :code:`[day, month, year]`
        :rtype: list|None
        """

        # We map our regex numbers with with the right group order.
        # Note: please report to the method note for more information about the mapping.
        cases = {
            "first": [[1, 2, 3, 10, 11, 22, 26, 27, 28, 29, 32, 34, 38], [0, 1, 2]],
            "second": [[14, 15, 31, 33, 36, 37], [1, 0, 2]],
            "third": [
                [4, 5, 6, 7, 8, 9, 12, 13, 16, 17, 18, 19, 20, 21, 23, 24, 25, 30, 35],
                [2, 1, 0],
            ],
        }

        for case in cases:
            # We loop through the cases.

            # We get the case data.
            case_data = cases[case]

            if int(regex_number) in case_data[0]:
                # The regex number is into the currently read case data.

                # We return a list with the formatted elements.
                # 1. We convert the day to 2 digits.
                # 2. We convert the month to the unified format.
                # 3. We return the year.
                return [
                    self._convert_1_to_2_digits(matched_result[case_data[1][0]]),
                    self._convert_or_shorten_month(matched_result[case_data[1][1]]),
                    str(matched_result[case_data[1][2]]),
                ]

        # The regex number is not already mapped.

        # We return the parsed data.
        return matched_result
def _cases_management ( self , regex_number , matched_result ) : # We map our regex numbers with with the right group order. # Note: please report to the method note for more information about the mapping. cases = { "first" : [ [ 1 , 2 , 3 , 10 , 11 , 22 , 26 , 27 , 28 , 29 , 32 , 34 , 38 ] , [ 0 , 1 , 2 ] ] , "second" : [ [ 14 , 15 , 31 , 33 , 36 , 37 ] , [ 1 , 0 , 2 ] ] , "third" : [ [ 4 , 5 , 6 , 7 , 8 , 9 , 12 , 13 , 16 , 17 , 18 , 19 , 20 , 21 , 23 , 24 , 25 , 30 , 35 ] , [ 2 , 1 , 0 ] , ] , } for case in cases : # We loop through the cases. # We get the case data. case_data = cases [ case ] if int ( regex_number ) in case_data [ 0 ] : # The regex number is into the currently read case data. # We return a list with the formatted elements. # 1. We convert the day to 2 digits. # 2. We convert the month to the unified format. # 3. We return the year. return [ self . _convert_1_to_2_digits ( matched_result [ case_data [ 1 ] [ 0 ] ] ) , self . _convert_or_shorten_month ( matched_result [ case_data [ 1 ] [ 1 ] ] ) , str ( matched_result [ case_data [ 1 ] [ 2 ] ] ) , ] # The regex number is not already mapped. # We return the parsed data. return matched_result
A little internal helper of self.format. (Avoiding of nested loops)

        .. note::
            Please note that the second value of the case represent the groups
            in order :code:`[day,month,year]`.

            This means that a :code:`[2,1,0]` will be for example for a date
            in format :code:`2017-01-02` where
            :code:`01` is the month.

        :param regex_number: The identifiant of the regex.
        :type regex_number: int

        :param matched_result: The matched result to format.
        :type matched_result: list

        :return:
            A list representing the expiration date.
            The list can be "decoded" like :code:`[day, month, year]`
        :rtype: list|None
A little internal helper of self . format . ( Avoiding of nested loops )