Moved supression for keyboard interrupt to display

This commit is contained in:
rfeistenauer 2020-10-20 14:40:17 +02:00
parent edd1211692
commit 1ed82116ce
4 changed files with 15 additions and 17 deletions

View File

@ -19,6 +19,7 @@ limitations under the License.
import time import time
import operator import operator
import collections import collections
import contextlib
from typing import Sequence from typing import Sequence
from . import CellularAutomaton from . import CellularAutomaton
@ -94,6 +95,7 @@ class CAWindow:
:param last_evolution_step: 0 = infinite | > 0 evolution step at which this method will stop :param last_evolution_step: 0 = infinite | > 0 evolution step at which this method will stop
Warning: is blocking until finished Warning: is blocking until finished
""" """
with contextlib.suppress(KeyboardInterrupt):
while self._is_not_user_terminated() and self._not_at_the_end(last_evolution_step): while self._is_not_user_terminated() and self._not_at_the_end(last_evolution_step):
time_ca_start = time.time() time_ca_start = time.time()
self._cellular_automaton.evolve(evolutions_per_draw) self._cellular_automaton.evolve(evolutions_per_draw)

View File

@ -19,7 +19,6 @@ limitations under the License.
# pylint: disable=missing-function-docstring # pylint: disable=missing-function-docstring
import random import random
import contextlib
import sys import sys
import os import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
@ -65,5 +64,4 @@ class ConwaysCA(CellularAutomaton):
if __name__ == "__main__": if __name__ == "__main__":
with contextlib.suppress(KeyboardInterrupt):
CAWindow(cellular_automaton=ConwaysCA()).run(evolutions_per_second=40) CAWindow(cellular_automaton=ConwaysCA()).run(evolutions_per_second=40)

View File

@ -20,7 +20,6 @@ limitations under the License.
# pylint: disable=no-self-use # pylint: disable=no-self-use
import random import random
import contextlib
import sys import sys
import os import os
from typing import Sequence from typing import Sequence
@ -53,5 +52,4 @@ def state_to_color(current_state: Sequence) -> Sequence:
if __name__ == "__main__": if __name__ == "__main__":
with contextlib.suppress(KeyboardInterrupt):
CAWindow(cellular_automaton=StarFallAutomaton(), state_to_color_cb=state_to_color).run() CAWindow(cellular_automaton=StarFallAutomaton(), state_to_color_cb=state_to_color).run()

View File

@ -7,7 +7,7 @@ with open('README.md') as f:
setup( setup(
name="cellular_automaton", name="cellular_automaton",
version="1.0.0", version="1.0.1",
author="Richard Feistenauer", author="Richard Feistenauer",
author_email="r.feistenauer@web.de", author_email="r.feistenauer@web.de",
packages=find_packages(exclude=('tests', 'docs', 'examples')), packages=find_packages(exclude=('tests', 'docs', 'examples')),