ripple-down-rules 0.5.87__py3-none-any.whl → 0.5.88__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- __version__ = "0.5.87"
1
+ __version__ = "0.5.88"
2
2
 
3
3
  import logging
4
4
  logger = logging.Logger("rdr")
@@ -20,12 +20,15 @@ from ..datastructures.dataclasses import CaseQuery
20
20
  from ..datastructures.enums import PromptFor
21
21
  from .ipython_custom_shell import IPythonShell
22
22
  from ..utils import make_list
23
+ from threading import Lock
23
24
 
24
25
 
25
26
  class UserPrompt:
26
27
  """
27
28
  A class to handle user prompts for the RDR.
28
29
  """
30
+ shell_lock: Lock = Lock() # To ensure that only one thread can access the shell at a time
31
+
29
32
  def __init__(self, viewer: Optional[RDRCaseViewer] = None):
30
33
  """
31
34
  Initialize the UserPrompt class.
@@ -143,17 +146,7 @@ class UserPrompt:
143
146
  """
144
147
  while True:
145
148
  if user_input is None:
146
- if self.viewer is None:
147
- shell = IPythonShell() if shell is None else shell
148
- shell.run()
149
- user_input = shell.user_input
150
- else:
151
- app = QApplication.instance()
152
- if app is None:
153
- raise RuntimeError("QApplication instance is None. Please run the application first.")
154
- self.viewer.show()
155
- app.exec()
156
- user_input = self.viewer.user_input
149
+ user_input = self.start_shell_and_get_user_input(shell=shell)
157
150
  if user_input is None or user_input == 'exit':
158
151
  return user_input, None
159
152
  self.print_func(f"{Fore.GREEN}Captured User input: {Style.RESET_ALL}")
@@ -166,3 +159,24 @@ class UserPrompt:
166
159
  logging.error(msg)
167
160
  self.print_func(f"{Fore.RED}{msg}{Style.RESET_ALL}")
168
161
  user_input = None
162
+
163
+ def start_shell_and_get_user_input(self, shell: Optional[IPythonShell] = None) -> Optional[str]:
164
+ """
165
+ Start the shell and get user input.
166
+
167
+ :param shell: The Ipython shell to use for prompting the user.
168
+ :return: The user input.
169
+ """
170
+ with self.shell_lock:
171
+ if self.viewer is None:
172
+ shell = IPythonShell() if shell is None else shell
173
+ shell.run()
174
+ user_input = shell.user_input
175
+ else:
176
+ app = QApplication.instance()
177
+ if app is None:
178
+ raise RuntimeError("QApplication instance is None. Please run the application first.")
179
+ self.viewer.show()
180
+ app.exec()
181
+ user_input = self.viewer.user_input
182
+ return user_input
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.5.87
3
+ Version: 0.5.88
4
4
  Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
5
5
  Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,4 +1,4 @@
1
- ripple_down_rules/__init__.py,sha256=GkugTXRcQu2cnGcyrT7Ra2SGmRhDvnkbdHlrvXqCmfw,100
1
+ ripple_down_rules/__init__.py,sha256=1-yDhteLcoAmFlskcFftLSXjoVeZ4jsY2e8IW2ikZsw,100
2
2
  ripple_down_rules/experts.py,sha256=J4VaYPKrAMNcoP0JRenZpx9IHLLoeFdl0QZKZzjFFkM,12768
3
3
  ripple_down_rules/helpers.py,sha256=v4oE7C5PfQUVJfSUs1FfLHEwrJXEHJLn4vJhJMvyCR8,4453
4
4
  ripple_down_rules/rdr.py,sha256=C6bvlq6MsKa2Mym1wW6JUMj705aCaoihTP279TM6eT0,55218
@@ -15,10 +15,10 @@ ripple_down_rules/user_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
15
15
  ripple_down_rules/user_interface/gui.py,sha256=_lgZAUXxxaBUFQJAHjA5TBPp6XEvJ62t-kSN8sPsocE,27379
16
16
  ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=6v99tlNcfRyZpnPxq3FfqgFgxbJ5zkA2jVAXamTH1C0,6575
17
17
  ripple_down_rules/user_interface/object_diagram.py,sha256=FEa2HaYR9QmTE6NsOwBvZ0jqmu3DKyg6mig2VE5ZP4Y,4956
18
- ripple_down_rules/user_interface/prompt.py,sha256=Liu24-wuL12mg2xI7FBvnL6T1eyykCcMZ3AeKkkYwpA,8283
18
+ ripple_down_rules/user_interface/prompt.py,sha256=kALi6NjHOjsHrTIf-5AUU7r-9IP8K2fMcqLGqqLDDiA,8775
19
19
  ripple_down_rules/user_interface/template_file_creator.py,sha256=ELHYhZEjHsMdG5ebbOghfZtPBpPtuJDWQRAkLpfcSFM,13553
20
- ripple_down_rules-0.5.87.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
- ripple_down_rules-0.5.87.dist-info/METADATA,sha256=L_EDvPOt6ibGEoNS6qgGXSFQ5zJkJdpPCKlB937_vzc,48214
22
- ripple_down_rules-0.5.87.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- ripple_down_rules-0.5.87.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
- ripple_down_rules-0.5.87.dist-info/RECORD,,
20
+ ripple_down_rules-0.5.88.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
+ ripple_down_rules-0.5.88.dist-info/METADATA,sha256=WEpFPvZh5GgYu-QHxLRGM79HTbKAL4QvGMj-rH09Q4A,48214
22
+ ripple_down_rules-0.5.88.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ ripple_down_rules-0.5.88.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
+ ripple_down_rules-0.5.88.dist-info/RECORD,,