Пример #1
0
 def test_regex(self):
     replacement = "@case_id stuff"
     cases = [
         ('./lmp < 570.5', '%s/lmp < 570.5'),
         ('stuff ./lmp < 570.', 'stuff %s/lmp < 570.'),
         ('.53 < hello.', '.53 < hello%s'),
     ]
     for case in cases:
         self.assertEqual(
             dot_interpolate(case[0], replacement),
             case[1] % replacement
         )
Пример #2
0
 def test_regex(self):
     replacement = "@case_id stuff"
     cases = [
         ('./lmp < 570.5', '%s/lmp < 570.5'),
         ('stuff ./lmp < 570.', 'stuff %s/lmp < 570.'),
         ('.53 < hello.', '.53 < hello%s'),
         ('./name + ", Jr."', '%s/name + ", Jr."'),
         ("./name + ', Jr.'", "%s/name + ', Jr.'"),
         ("'a.b' > .", "'a.b' > %s"),
         ("\"it's a dot .\" > .", "\"it's a dot .\" > %s"),
         ("\"it's a \\\"dot\\\" .\" > .", "\"it's a \\\"dot\\\" .\" > %s"),
     ]
     for case in cases:
         self.assertEqual(
             dot_interpolate(case[0], replacement),
             case[1] % replacement
         )
Пример #3
0
 def combine_and_interpolate_V1_filters(cls, columns, app, module, detail):
     """
     Return a single filter xpath generated by ANDing together the given
     componenets. Also replaces "."s with the corresponding xpath. The
     interpolation here is specific to v1 apps! use
     combine_and_interpolate_V2_filters for V2 apps.
     :param column_filters: A list of columns
     :param app:
     :param module:
     :param detail:
     :return:
     """
     filters = []
     for i, column in enumerate(columns):
         if column.format == 'filter':
             value = dot_interpolate(
                 column.filter_xpath,
                 '%s_%s_%s' % (column.model, column.field, i + 1))
             filters.append("(%s)" % value)
     xpath = ' and '.join(filters)
     return cls.partial_escape(xpath)
Пример #4
0
    def combine_and_interpolate_V2_filters(cls, columns, app, module, detail):
        """
        Return a single filter xpath generated by ANDing together the given
        componenets. Also replaces "."s with the corresponding xpath.
        The interpolation here is specific to v2 apps! use
        combine_and_interpolate_V1_filters for V1 apps.
        :param column_filters: A list of columns
        :param app:
        :param module:
        :param detail:
        :return:
        """
        interpolated_filters = []
        for column in columns:
            if column.format == "filter":
                # filters might have a "." in them like: . = "VT"
                # We need to replace these dots with the names of the
                # properties that they refer to.
                #
                # So, if we had a case property called "state", the filter
                # xpath would be converted to: state = "VT"

                # The string that will replace "."s
                replacer_xpath = get_column_xpath_generator(
                    app, module, detail, column
                ).xpath

                # The filter with "."s replaced
                interpolated_xpath = dot_interpolate(
                    column.filter_xpath, replacer_xpath
                )

                interpolated_filters.append(interpolated_xpath)

        combined_filter = ' and '.join(
            '(%s)' % f for f in interpolated_filters
        )

        return combined_filter
Пример #5
0
 def combine_and_interpolate_V1_filters(cls, columns, app, module, detail):
     """
     Return a single filter xpath generated by ANDing together the given
     componenets. Also replaces "."s with the corresponding xpath. The
     interpolation here is specific to v1 apps! use
     combine_and_interpolate_V2_filters for V2 apps.
     :param column_filters: A list of columns
     :param app:
     :param module:
     :param detail:
     :return:
     """
     filters = []
     for i, column in enumerate(columns):
         if column.format == 'filter':
             value = dot_interpolate(
                 column.filter_xpath,
                 '%s_%s_%s' % (column.model, column.field, i + 1)
             )
             filters.append("(%s)" % value)
     xpath = ' and '.join(filters)
     return cls.partial_escape(xpath)
Пример #6
0
    def combine_and_interpolate_V2_filters(cls, columns, app, module, detail):
        """
        Return a single filter xpath generated by ANDing together the given
        componenets. Also replaces "."s with the corresponding xpath.
        The interpolation here is specific to v2 apps! use
        combine_and_interpolate_V1_filters for V1 apps.
        :param column_filters: A list of columns
        :param app:
        :param module:
        :param detail:
        :return:
        """
        interpolated_filters = []
        for column in columns:
            if column.format == "filter":
                # filters might have a "." in them like: . = "VT"
                # We need to replace these dots with the names of the
                # properties that they refer to.
                #
                # So, if we had a case property called "state", the filter
                # xpath would be converted to: state = "VT"

                # The string that will replace "."s
                replacer_xpath = get_column_xpath_generator(
                    app, module, detail, column).xpath

                # The filter with "."s replaced
                interpolated_xpath = dot_interpolate(column.filter_xpath,
                                                     replacer_xpath)

                interpolated_filters.append(interpolated_xpath)

        combined_filter = ' and '.join('(%s)' % f
                                       for f in interpolated_filters)

        return combined_filter
Пример #7
0
 def xpath_function(self):
     return dot_interpolate(self.column.calc_xpath, self.xpath)
Пример #8
0
 def xpath_function(self):
     return dot_interpolate(self.column.calc_xpath, self.xpath)
Пример #9
0
 def filter_xpath(self):
     return dot_interpolate(self.column.filter_xpath, self.xpath)
Пример #10
0
 def filter_xpath(self):
     return dot_interpolate(self.column.filter_xpath, self.xpath)