13
13
from .interp_common import call_builtin_func , cast_to_python_int , cast_to_python
14
14
from .state import get_display
15
15
16
- from preql .settings import color_theme
16
+ from preql .settings import color_theme , Display as DisplaySettings
17
+
18
+
17
19
18
20
19
- TABLE_PREVIEW_SIZE = 16
20
- LIST_PREVIEW_SIZE = 128
21
- MAX_AUTO_COUNT = 10000
22
21
23
22
@dp_type
24
23
def pql_repr (t : T .function , value ):
@@ -116,8 +115,6 @@ def _html_table(name, count_str, rows, offset, has_more, colors):
116
115
return '%s<table class="preql_table">%s%s</table>' % (header , ths , '\n ' .join (trs )) + style
117
116
118
117
119
- from preql .settings import color_theme
120
-
121
118
def _rich_table (name , count_str , rows , offset , has_more , colors = True , show_footer = False ):
122
119
header = 'table '
123
120
if name :
@@ -176,15 +173,16 @@ def _view_table(table, size, offset):
176
173
177
174
def table_inline_repr (self ):
178
175
offset = 0
179
- table_name , rows , = _view_table (self , TABLE_PREVIEW_SIZE , offset )
176
+ table_name , rows , = _view_table (self , DisplaySettings . TABLE_PREVIEW_SIZE_SHELL , offset )
180
177
return '[%s]' % ', ' .join (repr (r ) for r in rows )
181
178
182
179
183
180
184
181
def table_repr (self , offset = 0 ):
182
+ max_count = DisplaySettings .MAX_AUTO_COUNT
185
183
186
- count = cast_to_python_int (call_builtin_func ('count' , [table_limit (self , MAX_AUTO_COUNT )]))
187
- if count == MAX_AUTO_COUNT :
184
+ count = cast_to_python_int (call_builtin_func ('count' , [table_limit (self , max_count )]))
185
+ if count == max_count :
188
186
count_str = f'>={ count } '
189
187
else :
190
188
count_str = f'={ count } '
@@ -197,12 +195,12 @@ def table_repr(self, offset=0):
197
195
198
196
# TODO load into preql and repr, instead of casting to python
199
197
table_f = _rich_table
200
- preview = TABLE_PREVIEW_SIZE
198
+ preview = DisplaySettings . TABLE_PREVIEW_SIZE_SHELL
201
199
colors = True
202
200
display = get_display ()
203
201
204
202
if display .format == 'html' :
205
- preview = TABLE_PREVIEW_SIZE * 10
203
+ preview = DisplaySettings . TABLE_PREVIEW_SIZE_HTML
206
204
table_f = _html_table
207
205
elif display .format == 'text' :
208
206
colors = False
0 commit comments