From 8ea9073f0c8dce61141a8c506bc790ad45196904 Mon Sep 17 00:00:00 2001 From: Niru Maheswaranathan Date: Tue, 24 Oct 2017 02:03:39 -0700 Subject: [PATCH] Improves irregular table width for international languages --- .gitignore | 1 + README.md | 1 + setup.py | 2 +- tableprint/metadata.py | 2 +- tableprint/utils.py | 3 ++- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 10ee80d..d75da01 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ lib64/ docs/_build .coverage .mypy_cache/ +tags diff --git a/README.md b/README.md index f3d0cb9..77a70fb 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Hosted at Read The Docs: [tableprint.readthedocs.org](http://tableprint.readthed ## 🛠 Changelog | Version | Release Date | Description | | ---: | :---: | :--- | +| 0.8.0 | Oct 24 2017 | Improves support for international languages | 0.7.0 | May 26 2017 | Adds a TableContext context manager for easy creation of dynamic tables (tables that update periodically). Adds the ability to pass a list or tuple of widths to specify different widths for different columns | 0.6.9 | May 25 2017 | Splitting the tableprint.py module into a pacakge with multiple files | 0.6.7 | May 25 2017 | Fixes some bugs with ANSI escape sequences diff --git a/setup.py b/setup.py index 3303b42..152e715 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ setup( # project is installed. For an analysis of "install_requires" vs pip's # requirements files see: # https://packaging.python.org/en/latest/requirements.html - install_requires=['numpy', 'six', 'future'], + install_requires=['numpy', 'six', 'future', 'wcwidth'], # List additional groups of dependencies here (e.g. development dependencies). # You can install these using the following syntax, for example: diff --git a/tableprint/metadata.py b/tableprint/metadata.py index 9da41ee..2b1f034 100644 --- a/tableprint/metadata.py +++ b/tableprint/metadata.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Version info -__version__ = '0.7.0' +__version__ = '0.8.0' __license__ = 'MIT' # Project description(s) diff --git a/tableprint/utils.py b/tableprint/utils.py index d37842a..189fcf8 100644 --- a/tableprint/utils.py +++ b/tableprint/utils.py @@ -3,6 +3,7 @@ Tableprint utilities """ from __future__ import print_function, unicode_literals +from wcwidth import wcswidth import re import numpy as np @@ -68,7 +69,7 @@ def humantime(time): def ansi_len(string): """Extra length due to any ANSI sequences in the string.""" - return len(string) - len(re.compile(r'\x1b[^m]*m').sub('', string)) + return len(string) - wcswidth(re.compile(r'\x1b[^m]*m').sub('', string)) def format_line(data, linestyle):