Commit 3469d0cc authored by Ondřej Nový's avatar Ondřej Nový

New upstream version 1.6.0

parent 105c1b8e
......@@ -22,3 +22,4 @@ Jan Balster
Grig Gheorghiu
Bob Ippolito
Christian Tismer
Wim Glenn
1.6.0 (2018-08-27)
==================
- add ``TerminalWriter.width_of_current_line`` (i18n version of
``TerminalWriter.chars_on_current_line``), a read-only property
that tracks how wide the current line is, attempting to take
into account international characters in the calculation.
1.5.4 (2018-06-27)
==================
......@@ -80,7 +88,7 @@ This issue was fixed in the 1.5.1 release.
1.4.30
==================================================
- fix issue68 an assert with a multiline list comprehension
- fix issue68 an assert with a multiline list comprehension
was not reported correctly. Thanks Henrik Heibuerger.
......@@ -108,7 +116,7 @@ This issue was fixed in the 1.5.1 release.
- allow a new ensuresyspath="append" mode for py.path.local.pyimport()
so that a neccessary import path is appended instead of prepended to
sys.path
sys.path
- strike undocumented, untested argument to py.path.local.pypkgpath
......@@ -156,10 +164,10 @@ This issue was fixed in the 1.5.1 release.
thus triggering the alias module to resolve and blowing
up with ImportError. The negative side is that something
like "py.test.X" will now result in None instead of "importerror: pytest"
if pytest is not installed. But you shouldn't import "py.test"
if pytest is not installed. But you shouldn't import "py.test"
anyway anymore.
- adapt one svn test to only check for any exception instead
- adapt one svn test to only check for any exception instead
of specific ones because different svn versions cause different
errors and we don't care.
......@@ -182,8 +190,8 @@ This issue was fixed in the 1.5.1 release.
its output even if it didn't flush itself.
- refactor traceback generation in light of pytest issue 364
(shortening tracebacks). you can now set a new traceback style
on a per-entry basis such that a caller can force entries to be
(shortening tracebacks). you can now set a new traceback style
on a per-entry basis such that a caller can force entries to be
isplayed as short or long entries.
- win32: py.path.local.sysfind(name) will preferrably return files with
......@@ -195,7 +203,7 @@ This issue was fixed in the 1.5.1 release.
- ignore unicode decode errors in xmlescape. Thanks Anatoly Bubenkoff.
- on python2 modify traceback.format_exception_only to match python3
- on python2 modify traceback.format_exception_only to match python3
behaviour, namely trying to print unicode for Exception instances
- use a safer way for serializing exception reports (helps to fix
......@@ -225,7 +233,7 @@ Changes between 1.4.17 and 1.4.18
- introduce path.ensure_dir() as a synonym for ensure(..., dir=1)
- some unicode/python3 related fixes wrt to path manipulations
(if you start passing unicode particular in py2 you might
(if you start passing unicode particular in py2 you might
still get problems, though)
Changes between 1.4.16 and 1.4.17
......@@ -292,7 +300,7 @@ Changes between 1.4.12 and 1.4.13
Changes between 1.4.11 and 1.4.12
==================================================
- fix python2.4 support - for pre-AST interpreters re-introduce
- fix python2.4 support - for pre-AST interpreters re-introduce
old way to find statements in exceptions (closes pytest issue 209)
- add tox.ini to distribution
- fix issue23 - print *,** args information in tracebacks,
......@@ -310,7 +318,7 @@ Changes between 1.4.10 and 1.4.11
unicodeencode/decode problems, amend according test
- introduce py.builtin.text and py.builtin.bytes
to point to respective str/unicode (py2) and bytes/str (py3) types
- fix error handling on win32/py33 for ENODIR
- fix error handling on win32/py33 for ENODIR
Changes between 1.4.9 and 1.4.10
==================================================
......@@ -347,12 +355,12 @@ Changes between 1.4.6 and 1.4.7
Changes between 1.4.5 and 1.4.6
==================================================
- help to fix pytest issue99: unify output of
- help to fix pytest issue99: unify output of
ExceptionInfo.getrepr(style="native") with ...(style="long")
- fix issue7: source.getstatementrange() now raises proper error
if no valid statement can be found
- fix issue8: fix code and tests of svnurl/svnwc to work on subversion 1.7 -
note that path.status(updates=1) will not properly work svn-17's status
- fix issue8: fix code and tests of svnurl/svnwc to work on subversion 1.7 -
note that path.status(updates=1) will not properly work svn-17's status
--xml output is broken.
- make source.getstatementrange() more resilent about non-python code frames
(as seen from jnja2)
......@@ -421,7 +429,7 @@ Changes between 1.3.4 and 1.4.0
- py.test was moved to a separate "pytest" package. What remains is
a stub hook which will proxy ``import py.test`` to ``pytest``.
- all command line tools ("py.cleanup/lookup/countloc/..." moved
- all command line tools ("py.cleanup/lookup/countloc/..." moved
to "pycmd" package)
- removed the old and deprecated "py.magic" namespace
- use apipkg-1.1 and make py.apipkg.initpkg|ApiModule available
......
Metadata-Version: 1.2
Name: py
Version: 1.5.4
Version: 1.6.0
Summary: library with cross-python path, ini-parsing, io, code, log facilities
Home-page: http://py.readthedocs.io/
Author: holger krekel, Ronny Pfannschmidt, Benjamin Peterson and others
......@@ -9,7 +9,7 @@ License: MIT license
Description: .. image:: https://img.shields.io/pypi/v/py.svg
:target: https://pypi.org/project/py
.. image:: https://anaconda.org/conda-forge/py/badges/version.svg
.. image:: https://img.shields.io/conda/vn/conda-forge/py.svg
:target: https://anaconda.org/conda-forge/py
.. image:: https://img.shields.io/pypi/pyversions/pytest.svg
......@@ -62,6 +62,7 @@ Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
.. image:: https://img.shields.io/pypi/v/py.svg
:target: https://pypi.org/project/py
.. image:: https://anaconda.org/conda-forge/py/badges/version.svg
.. image:: https://img.shields.io/conda/vn/conda-forge/py.svg
:target: https://anaconda.org/conda-forge/py
.. image:: https://img.shields.io/pypi/pyversions/pytest.svg
......
......@@ -13,14 +13,20 @@ environment:
- TOXENV: "py36-pytest29"
- TOXENV: "py36-pytest30"
- TOXENV: "py36-pytest31"
- TOXENV: "py37-pytest30"
- TOXENV: "py37-pytest31"
install:
- echo Installed Pythons
- dir c:\Python*
- C:\Python36\python -m pip install --upgrade --pre tox
- C:\Python37\python -m pip install --upgrade --pre tox
build: false # Not a C# project, build stuff at the test step instead.
test_script:
- C:\Python36\python -m tox
- C:\Python37\python -m tox
# We don't deploy anything on tags with AppVeyor, we use Travis instead, so we
# might as well save resources
skip_tags: true
import py
import timeit
class Listdir:
numiter = 100000
......@@ -70,6 +68,6 @@ if __name__ == "__main__":
for i in xrange(cls.numiter):
inst.run()
elapsed = time.time() - now
print "%s: %d loops took %.2f seconds, per call %.6f" %(
print("%s: %d loops took %.2f seconds, per call %.6f" %(
cls.__name__,
cls.numiter, elapsed, elapsed / cls.numiter)
cls.numiter, elapsed, elapsed / cls.numiter))
......@@ -8,6 +8,6 @@ doc = html.html(
html.body(
[html.p(p) for p in paras]))
print unicode(doc).encode('latin1')
print(unicode(doc).encode('latin1'))
......@@ -20,4 +20,4 @@ doc = my.html(
)
)
print doc.unicode(indent=2)
print(doc.unicode(indent=2))
......@@ -12,6 +12,6 @@ doc = ns.books(
ns.title("Java for Python programmers"),),
publisher="N.N",
)
print doc.unicode(indent=2).encode('utf8')
print(doc.unicode(indent=2).encode('utf8'))
......@@ -7,7 +7,7 @@ installation info in a nutshell
**PyPI name**: py_
**Pythons**: CPython 2.7, 3.4, 3.5, 3.6, PyPy-5.4
**Pythons**: CPython 2.7, 3.4, 3.5, 3.6, 3.7, PyPy-5.4
**Operating systems**: Linux, Windows, OSX, Unix
......
Metadata-Version: 1.2
Name: py
Version: 1.5.4
Version: 1.6.0
Summary: library with cross-python path, ini-parsing, io, code, log facilities
Home-page: http://py.readthedocs.io/
Author: holger krekel, Ronny Pfannschmidt, Benjamin Peterson and others
......@@ -9,7 +9,7 @@ License: MIT license
Description: .. image:: https://img.shields.io/pypi/v/py.svg
:target: https://pypi.org/project/py
.. image:: https://anaconda.org/conda-forge/py/badges/version.svg
.. image:: https://img.shields.io/conda/vn/conda-forge/py.svg
:target: https://anaconda.org/conda-forge/py
.. image:: https://img.shields.io/pypi/pyversions/pytest.svg
......@@ -62,6 +62,7 @@ Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
......@@ -115,6 +115,7 @@ testing/io_/__init__.py
testing/io_/test_capture.py
testing/io_/test_saferepr.py
testing/io_/test_terminalwriter.py
testing/io_/test_terminalwriter_linewidth.py
testing/log/__init__.py
testing/log/test_log.py
testing/log/test_warning.py
......
......@@ -5,7 +5,7 @@ Helper functions for writing to terminals and files.
"""
import sys, os
import sys, os, unicodedata
import py
py3k = sys.version_info[0] >= 3
from py.builtin import text, bytes
......@@ -53,6 +53,21 @@ def get_terminal_width():
terminal_width = get_terminal_width()
char_width = {
'A': 1, # "Ambiguous"
'F': 2, # Fullwidth
'H': 1, # Halfwidth
'N': 1, # Neutral
'Na': 1, # Narrow
'W': 2, # Wide
}
def get_line_width(text):
text = unicodedata.normalize('NFC', text)
return sum(char_width.get(unicodedata.east_asian_width(c), 1) for c in text)
# XXX unify with _escaped func below
def ansi_print(text, esc, file=None, newline=True, flush=False):
if file is None:
......@@ -140,6 +155,7 @@ class TerminalWriter(object):
self.hasmarkup = should_do_markup(file)
self._lastlen = 0
self._chars_on_current_line = 0
self._width_of_current_line = 0
@property
def fullwidth(self):
......@@ -164,6 +180,16 @@ class TerminalWriter(object):
"""
return self._chars_on_current_line
@property
def width_of_current_line(self):
"""Return an estimate of the width so far in the current line.
.. versionadded:: 1.6.0
:rtype: int
"""
return self._width_of_current_line
def _escaped(self, text, esc):
if esc and self.hasmarkup:
text = (''.join(['\x1b[%sm' % cod for cod in esc]) +
......@@ -223,12 +249,17 @@ class TerminalWriter(object):
markupmsg = msg
write_out(self._file, markupmsg)
def _update_chars_on_current_line(self, text):
fields = text.rsplit('\n', 1)
if '\n' in text:
self._chars_on_current_line = len(fields[-1])
def _update_chars_on_current_line(self, text_or_bytes):
newline = b'\n' if isinstance(text_or_bytes, bytes) else '\n'
current_line = text_or_bytes.rsplit(newline, 1)[-1]
if isinstance(current_line, bytes):
current_line = current_line.decode('utf-8', errors='replace')
if newline in text_or_bytes:
self._chars_on_current_line = len(current_line)
self._width_of_current_line = get_line_width(current_line)
else:
self._chars_on_current_line += len(fields[-1])
self._chars_on_current_line += len(current_line)
self._width_of_current_line += get_line_width(current_line)
def line(self, s='', **kw):
self.write(s, **kw)
......
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
version = '1.5.4'
version = '1.6.0'
......@@ -30,6 +30,7 @@ def main():
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
......
# coding: utf-8
from __future__ import unicode_literals
from py._io.terminalwriter import TerminalWriter
def test_terminal_writer_line_width_init():
tw = TerminalWriter()
assert tw.chars_on_current_line == 0
assert tw.width_of_current_line == 0
def test_terminal_writer_line_width_update():
tw = TerminalWriter()
tw.write('hello world')
assert tw.chars_on_current_line == 11
assert tw.width_of_current_line == 11
def test_terminal_writer_line_width_update_with_newline():
tw = TerminalWriter()
tw.write('hello\nworld')
assert tw.chars_on_current_line == 5
assert tw.width_of_current_line == 5
def test_terminal_writer_line_width_update_with_wide_text():
tw = TerminalWriter()
tw.write('乇乂ㄒ尺卂 ㄒ卄丨匚匚')
assert tw.chars_on_current_line == 11
assert tw.width_of_current_line == 21 # 5*2 + 1 + 5*2
def test_terminal_writer_line_width_update_with_wide_bytes():
tw = TerminalWriter()
tw.write('乇乂ㄒ尺卂 ㄒ卄丨匚匚'.encode('utf-8'))
assert tw.chars_on_current_line == 11
assert tw.width_of_current_line == 21
def test_terminal_writer_line_width_composed():
tw = TerminalWriter()
text = 'café food'
assert len(text) == 9
tw.write(text)
assert tw.chars_on_current_line == 9
assert tw.width_of_current_line == 9
def test_terminal_writer_line_width_combining():
tw = TerminalWriter()
text = 'café food'
assert len(text) == 10
tw.write(text)
assert tw.chars_on_current_line == 10
assert tw.width_of_current_line == 9
[tox]
envlist=py{27,34,35,36}-pytest{29,30,31}
# Skip py37-pytest29 as such a combination does not work (#192)
envlist=py{27,34,35,36}-pytest{29,30,31},py37-pytest{30,31}
[testenv]
changedir=testing
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment