Skip to content

Commit

Permalink
Merge pull request #84 from pavdmyt/release-version-1.1.0
Browse files Browse the repository at this point in the history
Release version 1.1.0
  • Loading branch information
pavdmyt authored Oct 4, 2020
2 parents f78459a + d01b332 commit fefdc93
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 36 deletions.
9 changes: 9 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Release History
===============

1.1.0 / 2020-10-04
------------------

* Add ``hidden()`` context manager #68
* fix(#70): ``hidden()`` exceptions handling
* Replace coveralls.io with codecov.io
* Update dependencies


1.0.0 / 2020-08-02
------------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ rm-build:
# https://github.com/pypa/readme_renderer#check-description-locally
# https://github.com/pypa/twine#twine-check
#
# pylint should be available as external tool
# twine should be available as external tool
#
# No way to add it as tool.poetry.dev-dependencies,
# since versions "<2" have known security vulnerabilities
Expand Down
20 changes: 9 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ Integration with other libraries

.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/hide_show.gif

Utilizing ``hide`` and ``show`` methods it is possible to toggle the display of
Utilizing ``hidden`` context manager it is possible to toggle the display of
the spinner in order to call custom methods that write to the terminal. This is
helpful for allowing easy usage in other frameworks like `prompt-toolkit`_.
Using the powerful ``print_formatted_text`` function allows you even to apply
Expand Down Expand Up @@ -298,19 +298,17 @@ HTML formats and CSS styles to the output:
with yaspin(text='Downloading images') as sp:
# task 1
time.sleep(1)
sp.hide()
print(HTML(
u'<b>></b> <msg>image 1</msg> <sub-msg>download complete</sub-msg>'
), style=style)
sp.show()
with sp.hidden():
print(HTML(
u'<b>></b> <msg>image 1</msg> <sub-msg>download complete</sub-msg>'
), style=style)
# task 2
time.sleep(2)
sp.hide()
print(HTML(
u'<b>></b> <msg>image 2</msg> <sub-msg>download complete</sub-msg>'
), style=style)
sp.show()
with sp.hidden():
print(HTML(
u'<b>></b> <msg>image 2</msg> <sub-msg>download complete</sub-msg>'
), style=style)
# finalize
sp.ok()
Expand Down
11 changes: 5 additions & 6 deletions examples/hide_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
~~~~~~~~~~~~~~~~~~
Basic usage of the ``hide`` and ``show`` methods.
Starting from yaspin v1.1.0 handled by ``hidden`` context manager.
"""

import sys
Expand All @@ -17,15 +18,13 @@ def main():
with yaspin(text="Downloading images") as sp:
# task 1
time.sleep(1)
sp.hide()
sys.stdout.write("> image 1 download complete\n")
sp.show()
with sp.hidden():
sys.stdout.write("> image 1 download complete\n")

# task 2
time.sleep(2)
sp.hide()
sys.stdout.write("> image 2 download complete\n")
sp.show()
with sp.hidden():
sys.stdout.write("> image 2 download complete\n")

# finalize
sp.green.ok("✔")
Expand Down
31 changes: 15 additions & 16 deletions examples/hide_show_prompt_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Usage of the ``hide`` and ``show`` methods with prompt_toolkit's printing.
Starting from yaspin v1.1.0 handled by ``hidden`` context manager.
Requires python-prompt-tooklit >= 2.0.1
https://github.com/jonathanslenders/python-prompt-toolkit/
Expand Down Expand Up @@ -44,25 +45,23 @@

# task 1
time.sleep(1)
sp.hide()
print(
HTML(
u"<b>></b> <msg>image 1</msg> <sub-msg>download complete</sub-msg>"
),
style=style,
)
sp.show()
with sp.hidden():
print(
HTML(
u"<b>></b> <msg>image 1</msg> <sub-msg>download complete</sub-msg>"
),
style=style,
)

# task 2
time.sleep(2)
sp.hide()
print(
HTML(
u"<b>></b> <msg>image 2</msg> <sub-msg>download complete</sub-msg>"
),
style=style,
)
sp.show()
with sp.hidden():
print(
HTML(
u"<b>></b> <msg>image 2</msg> <sub-msg>download complete</sub-msg>"
),
style=style,
)

# finalize
sp.green.ok("✔")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "yaspin"
version = "1.0.0"
version = "1.1.0"
description = "Yet Another Terminal Spinner"
license = "MIT"
authors = ["Pavlo Dmytrenko <mail@pavdmyt.com>"]
Expand Down
4 changes: 3 additions & 1 deletion tests/test_in_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ def test_spinner_hiding_with_context_manager_and_exception():
except ValueError:
pass
else:
assert False, "Expected a ValueError, something has eaten the exception"
assert (
False
), "Expected a ValueError, something has eaten the exception"

# make sure spinner is unhidden again
assert sp._hidden_level == 0
Expand Down

0 comments on commit fefdc93

Please sign in to comment.