def get_console_size(): """Return console size as tuple = (width, height). Returns (None,None) in non-interactive session. """ display_width = options.display.width # deprecated. display_height = options.display.max_rows # Consider # interactive shell terminal, can detect term size # interactive non-shell terminal (ipnb/ipqtconsole), cannot detect term # size non-interactive script, should disregard term size # in addition # width,height have default values, but setting to 'None' signals # should use Auto-Detection, But only in interactive shell-terminal. # Simple. yeah. if in_interactive_session(): if in_ipython_frontend(): # sane defaults for interactive non-shell terminal # match default for width,height in config_init try: from pandas.core.config import get_default_val terminal_width = get_default_val('display.width') terminal_height = get_default_val('display.max_rows') except ImportError: terminal_width, terminal_height = None, None else: # pure terminal terminal_width, terminal_height = get_terminal_size() else: terminal_width, terminal_height = None, None # Note if the User sets width/Height to None (auto-detection) # and we're in a script (non-inter), this will return (None,None) # caller needs to deal. return (display_width or terminal_width, display_height or terminal_height)
def get_console_size(): """Return console size as tuple = (width, height). Returns (None,None) in non-interactive session. """ from pandas import get_option from pandas.core import common as com display_width = get_option('display.width') # deprecated. display_height = get_option('display.height', silent=True) # Consider # interactive shell terminal, can detect term size # interactive non-shell terminal (ipnb/ipqtconsole), cannot detect term # size non-interactive script, should disregard term size # in addition # width,height have default values, but setting to 'None' signals # should use Auto-Detection, But only in interactive shell-terminal. # Simple. yeah. if com.in_interactive_session(): if com.in_ipython_frontend(): # sane defaults for interactive non-shell terminal # match default for width,height in config_init from pandas.core.config import get_default_val terminal_width = get_default_val('display.width') terminal_height = get_default_val('display.height') else: # pure terminal terminal_width, terminal_height = get_terminal_size() else: terminal_width, terminal_height = None, None # Note if the User sets width/Height to None (auto-detection) # and we're in a script (non-inter), this will return (None,None) # caller needs to deal. return (display_width or terminal_width, display_height or terminal_height)
cf.register_option("pprint_nest_depth", 3, pc_pprint_nest_depth, validator=is_int) cf.register_option("multi_sparse", True, pc_multi_sparse_doc, validator=is_bool) cf.register_option("encoding", detect_console_encoding(), pc_encoding_doc, validator=is_text) cf.register_option("expand_frame_repr", True, pc_expand_repr_doc) cf.register_option( "show_dimensions", "truncate", pc_show_dimensions_doc, validator=is_one_of_factory([True, False, "truncate"]) ) cf.register_option("chop_threshold", None, pc_chop_threshold_doc) cf.register_option("max_seq_items", 100, pc_max_seq_items) cf.register_option( "mpl_style", None, pc_mpl_style_doc, validator=is_one_of_factory([None, False, "default"]), cb=mpl_style_cb ) cf.register_option("height", 60, pc_height_doc, validator=is_instance_factory([type(None), int])) cf.register_option("width", 80, pc_width_doc, validator=is_instance_factory([type(None), int])) # redirected to width, make defval identical cf.register_option("line_width", get_default_val("display.width"), pc_line_width_doc) cf.register_option( "memory_usage", True, pc_memory_usage_doc, validator=is_one_of_factory([None, True, False, "deep"]) ) cf.register_option("unicode.east_asian_width", False, pc_east_asian_width_doc, validator=is_bool) cf.register_option("unicode.ambiguous_as_wide", False, pc_east_asian_width_doc, validator=is_bool) cf.register_option("latex.repr", False, pc_latex_repr_doc, validator=is_bool) cf.register_option("latex.escape", True, pc_latex_escape, validator=is_bool) cf.register_option("latex.longtable", False, pc_latex_longtable, validator=is_bool) cf.deprecate_option("display.line_width", msg=pc_line_width_deprecation_warning, rkey="display.width") cf.deprecate_option("display.height", msg=pc_height_deprecation_warning, rkey="display.max_rows") tc_sim_interactive_doc = """ : boolean
cf.register_option('encoding', detect_console_encoding(), pc_encoding_doc, validator=is_text) cf.register_option('expand_frame_repr', True, pc_expand_repr_doc) cf.register_option('show_dimensions', 'truncate', pc_show_dimensions_doc, validator=is_one_of_factory([True, False, 'truncate'])) cf.register_option('chop_threshold', None, pc_chop_threshold_doc) cf.register_option('max_seq_items', 100, pc_max_seq_items) cf.register_option('mpl_style', None, pc_mpl_style_doc, validator=is_one_of_factory([None, False, 'default']), cb=mpl_style_cb) cf.register_option('height', 60, pc_height_doc, validator=is_instance_factory([type(None), int])) cf.register_option('width', 80, pc_width_doc, validator=is_instance_factory([type(None), int])) # redirected to width, make defval identical cf.register_option('line_width', get_default_val('display.width'), pc_line_width_doc) cf.register_option('memory_usage', True, pc_memory_usage_doc, validator=is_one_of_factory([None, True, False, 'deep'])) cf.register_option('unicode.east_asian_width', False, pc_east_asian_width_doc, validator=is_bool) cf.register_option('unicode.ambiguous_as_wide', False, pc_east_asian_width_doc, validator=is_bool) cf.register_option('latex.repr', False, pc_latex_repr_doc, validator=is_bool) cf.register_option('latex.escape', True, pc_latex_escape, validator=is_bool) cf.register_option('latex.longtable', False, pc_latex_longtable, validator=is_bool) cf.register_option('latex.multicolumn', True, pc_latex_multicolumn,
cf.register_option('encoding', detect_console_encoding(), pc_encoding_doc, validator=is_text) cf.register_option('expand_frame_repr', True, pc_expand_repr_doc) cf.register_option('show_dimensions', 'truncate', pc_show_dimensions_doc, validator=is_one_of_factory([True, False, 'truncate'])) cf.register_option('chop_threshold', None, pc_chop_threshold_doc) cf.register_option('max_seq_items', 100, pc_max_seq_items) cf.register_option('mpl_style', None, pc_mpl_style_doc, validator=is_one_of_factory([None, False, 'default']), cb=mpl_style_cb) cf.register_option('height', 60, pc_height_doc, validator=is_instance_factory([type(None), int])) cf.register_option('width', 80, pc_width_doc, validator=is_instance_factory([type(None), int])) # redirected to width, make defval identical cf.register_option('line_width', get_default_val('display.width'), pc_line_width_doc) cf.register_option('memory_usage', True, pc_memory_usage_doc, validator=is_one_of_factory([None, True, False, 'deep'])) cf.register_option('unicode.east_asian_width', False, pc_east_asian_width_doc, validator=is_bool) cf.register_option('unicode.ambiguous_as_wide', False, pc_east_asian_width_doc, validator=is_bool) cf.register_option('latex.repr', False, pc_latex_repr_doc, validator=is_bool) cf.register_option('latex.escape', True, pc_latex_escape, validator=is_bool) cf.register_option('latex.longtable', False, pc_latex_longtable, validator=is_bool)