Improves irregular table width for international languages

This commit is contained in:
Niru Maheswaranathan
2017-10-24 02:03:39 -07:00
parent ac2accb231
commit 8ea9073f0c
5 changed files with 6 additions and 3 deletions

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ lib64/
docs/_build
.coverage
.mypy_cache/
tags

View File

@@ -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

View File

@@ -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:

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Version info
__version__ = '0.7.0'
__version__ = '0.8.0'
__license__ = 'MIT'
# Project description(s)

View File

@@ -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):