From d3b4a385741f690f3d2e91bb56249cafca809079 Mon Sep 17 00:00:00 2001 From: Paul Makepeace Date: Mon, 25 Apr 2011 11:59:18 -0400 Subject: [PATCH] Remove RefineProject.columns (not really used) and tidy up get_models(). --- google/refine.py | 19 ++++++++----------- google/test/test_refine.py | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/google/refine.py b/google/refine.py index c1d2581..8a610e8 100644 --- a/google/refine.py +++ b/google/refine.py @@ -392,12 +392,12 @@ class RefineProject: project_name or project_id) self.project_id = project_id self.project_name = project_name - self.columns = [] # following filled in by get_models() - self.column_order = {} # order of column in UI - self.rows_response_factory = None - self.get_models() self.engine = Engine() self.sorting = Sorting() + # following filled in by get_models() + self.column_order = {} # order of column in UI + self.rows_response_factory = None # for parsing get_rows() + self.get_models() def do_raw(self, command, data): """Issue a command to the server & return a response object.""" @@ -420,18 +420,15 @@ class RefineProject: get_rows().""" response = self.do_json('get-models', include_engine=False) column_model = response['columnModel'] - columns = column_model['columns'] - # Pre-extend the list in python - self.columns = [None] * len(columns) column_index = {} - for i, column in enumerate(columns): - cell_index, name = column['cellIndex'], column['name'] + for i, column in enumerate(column_model['columns']): + name = column['name'] self.column_order[name] = i - column_index[name] = cell_index - self.columns[i] = name + column_index[name] = column['cellIndex'] self.key_column = column_model['keyColumnName'] self.rows_response_factory = RowsResponseFactory(column_index) # TODO: implement rest + return response def wait_until_idle(self, polling_delay=0.5): while True: diff --git a/google/test/test_refine.py b/google/test/test_refine.py index 6b8cbcc..03a1a25 100644 --- a/google/test/test_refine.py +++ b/google/test/test_refine.py @@ -81,8 +81,8 @@ class RefineTest(RefineTestCase): def test_get_models(self): self.assertEqual(self.project.key_column, 'email') - self.assertTrue('email' in self.project.columns) - self.assertEqual(self.project.column_index['name'], 1) + self.assertTrue('email' in self.project.column_order) + self.assertEqual(self.project.column_order['name'], 1) def test_delete_project(self): self.assertTrue(self.project.delete())