Пример #1
0
    def get_variable_name(self, abbreviated_xpath):
        """
        If the abbreviated_xpath has been renamed in
        self.variable_names_json return that new name, otherwise
        return the original abbreviated_xpath.
        """
        if not hasattr(self, "_keys"):
            self._keys = self.get_keys()
        if not hasattr(self, "_headers"):
            self._headers = self.get_headers()

        if abbreviated_xpath not in self._keys:
            raise AssertionError(abbreviated_xpath)
        i = self._keys.index(abbreviated_xpath)
        header = self._headers[i]

        if not hasattr(self, "_variable_names"):
            from onadata.apps.viewer.models.column_rename import ColumnRename

            self._variable_names = ColumnRename.get_dict()

        if header in self._variable_names and self._variable_names[header]:
            return self._variable_names[header]

        return header
Пример #2
0
    def get_variable_name(self, abbreviated_xpath):
        """
        If the abbreviated_xpath has been renamed in
        self.variable_names_json return that new name, otherwise
        return the original abbreviated_xpath.
        """
        if not hasattr(self, "_keys"):
            self._keys = self.get_keys()
        if not hasattr(self, "_headers"):
            self._headers = self.get_headers()

        if abbreviated_xpath not in self._keys:
            raise AssertionError(abbreviated_xpath)
        i = self._keys.index(abbreviated_xpath)
        header = self._headers[i]

        if not hasattr(self, "_variable_names"):
            from onadata.apps.viewer.models.column_rename import ColumnRename

            self._variable_names = ColumnRename.get_dict()

        if header in self._variable_names and self._variable_names[header]:
            return self._variable_names[header]

        return header