Skip to content

Commit

Permalink
CLN: Remove io/formats/terminal.py
Browse files Browse the repository at this point in the history
Remaining is_terminal function is
used in core/config_init.py, and
as this function is not meant to
be public, we can move it there.

This will help with dependency
organization of pandas' modules.

Follow-up to pandas-devgh-25586.
  • Loading branch information
gfyoung committed Mar 29, 2019
1 parent 7721f70 commit 79755b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
19 changes: 17 additions & 2 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
is_bool, is_callable, is_instance_factory, is_int, is_one_of_factory,
is_text)

from pandas.io.formats.terminal import is_terminal

# compute

use_bottleneck_doc = """
Expand Down Expand Up @@ -287,6 +285,23 @@ def table_schema_cb(key):
_enable_data_resource_formatter(cf.get_option(key))


def is_terminal():
"""
Detect if Python is running in a terminal.
Returns True if Python is running in a terminal or False if not.
"""
try:
ip = get_ipython()
except NameError: # assume standard Python interpreter in a terminal
return True
else:
if hasattr(ip, 'kernel'): # IPython as a Jupyter kernel
return False
else: # IPython in a terminal
return True


with cf.config_prefix('display'):
cf.register_option('precision', 6, pc_precision_doc, validator=is_int)
cf.register_option('float_format', None, float_format_doc,
Expand Down
22 changes: 0 additions & 22 deletions pandas/io/formats/terminal.py

This file was deleted.

0 comments on commit 79755b1

Please sign in to comment.