| 1160 | range_constructor = Range |
| 1161 | |
| 1162 | def __init__(self, parent=None, session=None, **kwargs): |
| 1163 | if parent and session: |
| 1164 | raise ValueError('Need a parent or a session but not both') |
| 1165 | |
| 1166 | self.parent = parent |
| 1167 | self.session = parent.session if parent else session |
| 1168 | |
| 1169 | cloud_data = kwargs.get(self._cloud_data_key, {}) |
| 1170 | |
| 1171 | self.object_id = cloud_data.get('id', None) |
| 1172 | |
| 1173 | # Choose the main_resource passed in kwargs over parent main_resource |
| 1174 | main_resource = kwargs.pop('main_resource', None) or ( |
| 1175 | getattr(parent, 'main_resource', None) if parent else None) |
| 1176 | |
| 1177 | # append the encoded table path |
| 1178 | main_resource = "{}/tables('{}')".format(main_resource, quote(self.object_id)) |
| 1179 | |
| 1180 | super().__init__( |
| 1181 | protocol=parent.protocol if parent else kwargs.get('protocol'), |
| 1182 | main_resource=main_resource) |
| 1183 | |
| 1184 | self.name = cloud_data.get('name', None) |
| 1185 | self.show_headers = cloud_data.get('showHeaders', True) |
| 1186 | self.show_totals = cloud_data.get('showTotals', True) |
| 1187 | self.style = cloud_data.get('style', None) |
| 1188 | self.highlight_first_column = cloud_data.get('highlightFirstColumn', False) |
| 1189 | self.highlight_last_column = cloud_data.get('highlightLastColumn', False) |
| 1190 | self.show_banded_columns = cloud_data.get('showBandedColumns', False) |
| 1191 | self.show_banded_rows = cloud_data.get('showBandedRows', False) |
| 1192 | self.show_filter_button = cloud_data.get('showFilterButton', False) |
| 1193 | self.legacy_id = cloud_data.get('legacyId', False) |
| 1194 | |
| 1195 | def __str__(self): |
| 1196 | return self.__repr__() |