Skip to content

Commit

Permalink
1. make use of terminaltables3 instead of terminaltables where/w…
Browse files Browse the repository at this point in the history
…hen possible
  • Loading branch information
VanyaBelyaev committed Sep 5, 2024
1 parent fe78080 commit 90461e4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
4 changes: 3 additions & 1 deletion ReleaseNotes/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
1. add possibility to avodi coloring of the header row in the tables
1. add protection for double cpoulmn (`::`) for the expression strings
1. resurrect and improve `ostap.stats.corr2d` module with simple 2D-decorrelation utility

1. make use of `terminaltables3` instead of `terminaltables` where/when possible

## Backward incompatible

## Bug fixes

1. fix tiny bug in `histo_book`
1. fix tiny bug in printout of linear algebra objects

# v1.13.1.0

Expand Down
16 changes: 9 additions & 7 deletions ostap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,18 @@ endif()
find_python_module ( lmdb QUIET )
endif()

if ( ${PYTHON_VERSION} VERSION_GREATER_EQUAL "3.8" )
find_python_module ( terminaltables3 QUIET )
if ( NOT ${PY_terminaltables3_FOUND} )
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install terminaltables3 ${PIP_ARGS})
endif ()
else ()
find_python_module ( terminaltables QUIET )
if ( NOT ${PY_terminaltables_FOUND} )
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install terminaltables ${PIP_ARGS})
endif()

find_python_module ( terminaltables QUIET )
if ( NOT ${PY_terminaltables_FOUND} )
message ( "----> (warning) (optional) terminaltables is NOT found!" )
endif()

endif ()
endif ()

find_python_module ( tabulate QUIET )
if ( NOT ${PY_tabulate_FOUND} )
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install tabulate ${PIP_ARGS})
Expand Down
22 changes: 16 additions & 6 deletions ostap/logger/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,21 @@
from ostap.logger.colorized import infostr, allright, decolorize
from ostap.utils.basic import terminal_size
import textwrap, os, sys
# =============================================================================
try :
import terminaltables
except ImportError :
terminaltables = None
# =============================================================================
terminaltables = None
if ( 3 , 8 ) <= sys.version_info :
try :
import terminaltables3 as terminaltables
except ImportError :
terminaltables = None
# =============================================================================
if not terminaltables :
try :
import terminaltables
except ImportError :
terminaltables = None
pass

# =============================================================================
## environment variable
env_var = 'OSTAP_TABLE_STYLE'
Expand Down Expand Up @@ -327,7 +337,7 @@ def table ( rows ,
style = style )

title = allright ( title )

if 'ascii' == fmt or not isatty() :
table_instance = terminaltables.AsciiTable ( rows , title )
elif 'single' == fmt :
Expand Down

0 comments on commit 90461e4

Please sign in to comment.