Пример #1
0
    def load_table(self, table, verbose=False):
        """Loads the specified table

        Parameters
        ----------
        table : str, mandatory
            full qualified table name (i.e. schema name + table name)
        verbose : bool, optional, default 'False'
            flag to display information about the process

        Returns
        -------
        A table object
        """
        print("Retrieving table '"+str(table)+"'")
        connHandler = self.__getconnhandler()
        response = connHandler.execute_get("tables?tables="+table)
        if verbose:
            print(response.status, response.reason)
        isError = connHandler.check_launch_response_status(response, verbose, 200)
        if isError:
            print(response.status, response.reason)
            raise Exception(response.reason)
            return None
        print("Parsing table '"+str(table)+"'...")
        tsp = TableSaxParser()
        tsp.parseData(response)
        print("Done.")
        return tsp.get_table()
Пример #2
0
    def load_table(self, table, verbose=False):
        """Loads the specified table

        Parameters
        ----------
        table : str, mandatory
            full qualified table name (i.e. schema name + table name)
        verbose : bool, optional, default 'False'
            flag to display information about the process

        Returns
        -------
        A table object
        """
        print("Retrieving table '"+str(table)+"'")
        connHandler = self.__getconnhandler()
        response = connHandler.execute_get("tables?tables="+table)
        if verbose:
            print(response.status, response.reason)
        isError = connHandler.check_launch_response_status(response, verbose, 200)
        if isError:
            print(response.status, response.reason)
            raise requests.exceptions.HTTPError(response.reason)
            return None
        print("Parsing table '"+str(table)+"'...")
        tsp = TableSaxParser()
        tsp.parseData(response)
        print("Done.")
        return tsp.get_table()
Пример #3
0
def test_table_list_parser():
    fileName = data_path('test_tables.xml')
    file = open(fileName, 'r')
    parser = TableSaxParser()
    tables = parser.parseData(file)
    assert len(tables) == 2
    __check_table(tables[0], "table1", 2, ['table1_col1', 'table1_col2'])
    __check_table(tables[1], "table2", 3,
                  ['table2_col1', 'table2_col2', 'table2_col3'])
    file.close()
Пример #4
0
 def test_table_list_parser(self):
     fileName = data_path('test_tables.xml')
     file = open(fileName, 'r')
     parser = TableSaxParser()
     tables = parser.parseData(file)
     assert len(tables) == 2, \
         "Expected table list size: 2, found %d" % len(tables)
     self.__check_table(tables[0], "table1", 2,
                        ['table1_col1', 'table1_col2'])
     self.__check_table(tables[1], "table2", 3,
                        ['table2_col1', 'table2_col2', 'table2_col3'])
     file.close()
Пример #5
0
    def __load_tables(self,
                      only_names=False,
                      include_shared_tables=False,
                      verbose=False):
        """Loads all public tables

        Parameters
        ----------
        only_names : bool, TAP+ only, optional, default 'False'
            True to load table names only
        include_shared_tables : bool, TAP+, optional, default 'False'
            True to include shared tables
        verbose : bool, optional, default 'False'
            flag to display information about the process

        Returns
        -------
        A list of table objects
        """
        # share_info=true&share_accessible=true&only_tables=true
        flags = ""
        addedItem = False
        if only_names:
            flags = "only_tables=true"
            addedItem = True
        if include_shared_tables:
            if addedItem:
                flags += "&"
            flags += "share_accessible=true"
            addedItem = True
        print("Retrieving tables...")
        if flags != "":
            response = self.__connHandler.execute_get("tables?" + flags)
        else:
            response = self.__connHandler.execute_get("tables")
        if verbose:
            print(response.status, response.reason)
        isError = self.__connHandler.check_launch_response_status(
            response, verbose, 200)
        if isError:
            print(response.status, response.reason)
            raise requests.exceptions.HTTPError(response.reason)
            return None
        print("Parsing tables...")
        tsp = TableSaxParser()
        tsp.parseData(response)
        print("Done.")
        return tsp.get_tables()
Пример #6
0
 def test_table_list_parser(self):
     fileName = data_path('test_tables.xml')
     file = open(fileName, 'r')
     parser = TableSaxParser()
     tables = parser.parseData(file)
     assert len(tables) == 2, \
         "Expected table list size: 2, found %d" % len(tables)
     self.__check_table(tables[0],
                        "table1",
                        2,
                        ['table1_col1', 'table1_col2'])
     self.__check_table(tables[1],
                        "table2",
                        3,
                        ['table2_col1', 'table2_col2', 'table2_col3'])
     file.close()
Пример #7
0
    def __load_tables(self, only_names=False, include_shared_tables=False,
                      verbose=False):
        """Loads all public tables

        Parameters
        ----------
        only_names : bool, TAP+ only, optional, default 'False'
            True to load table names only
        include_shared_tables : bool, TAP+, optional, default 'False'
            True to include shared tables
        verbose : bool, optional, default 'False'
            flag to display information about the process

        Returns
        -------
        A list of table objects
        """
        # share_info=true&share_accessible=true&only_tables=true
        flags = ""
        addedItem = False
        if only_names:
            flags = "only_tables=true"
            addedItem = True
        if include_shared_tables:
            if addedItem:
                flags += "&"
            flags += "share_accessible=true"
            addedItem = True
        print("Retrieving tables...")
        if flags != "":
            response = self.__connHandler.execute_get("tables?"+flags)
        else:
            response = self.__connHandler.execute_get("tables")
        if verbose:
            print(response.status, response.reason)
        isError = self.__connHandler.check_launch_response_status(response,
                                                                  verbose,
                                                                  200)
        if isError:
            print(response.status, response.reason)
            raise Exception(response.reason)
            return None
        print("Parsing tables...")
        tsp = TableSaxParser()
        tsp.parseData(response)
        print("Done.")
        return tsp.get_tables()