From da740af8ab89f7e964cc48eb34102dadad327b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 16 May 2024 22:55:21 +0300 Subject: [PATCH] d --- v4/ContextController.py | 22 ++++++++++++++++++++++ v4/cli.py | 4 ++-- v4/cli_test.py | 4 ++-- v4/main.py | 11 +++++++++++ v4/memory_Context.py | 1 + 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 v4/ContextController.py diff --git a/v4/ContextController.py b/v4/ContextController.py new file mode 100644 index 0000000..ee8e673 --- /dev/null +++ b/v4/ContextController.py @@ -0,0 +1,22 @@ +import memory_Context + +class ContextController: + def __init__(self): + self.c = memory_createContext() + + def executeFunctions(self): + pass + + def reportCallbacks(self): + pass + + def set(self, field, value): + setattr(self.c, field, value) + self.c.recentField = field + self.executeFunctions() + self.reportCallbacks() + +ctrl = ContextController() +ctrl.callback(printOutput) + +ctrl.set("didLaunch", True) diff --git a/v4/cli.py b/v4/cli.py index c584941..8eb1d08 100644 --- a/v4/cli.py +++ b/v4/cli.py @@ -7,8 +7,8 @@ def cli_greetUser( c: memory_Context ) -> memory_Context: if ( - c.recentField == "launched" and - c.launched == True + c.recentField == "didLaunch" and + c.didLaunch == True ): c.outputGreeting = "OGS Memory Command Line Interface" c.recentField = "outputGreeting" diff --git a/v4/cli_test.py b/v4/cli_test.py index 447503d..52aa0dd 100644 --- a/v4/cli_test.py +++ b/v4/cli_test.py @@ -5,8 +5,8 @@ from memory_Context import * def cli_test_greetUser( ) -> str: c = memory_createContext() - c.launched = True - c.recentField = "launched" + c.didLaunch = True + c.recentField = "didLaunch" c = cli_greetUser(c) if ( c.recentField == "outputGreeting" diff --git a/v4/main.py b/v4/main.py index fc59a2c..fecfcfa 100644 --- a/v4/main.py +++ b/v4/main.py @@ -19,6 +19,17 @@ print(cli_test_greetUser()) ##print(cli_test_shouldReportIvalidItemSelection_outOfBoundsMin()) #print(cli_test_showHelp_h()) #print(cli_test_showHelp_help()) + +def printOutput(c): + if c.recentField.startswith("output")): + print(getatter(c, c.recentField)) + +ctrl = ContextController() +ctrl.callback(printOutput) + +ctrl.set("didLaunch", True) + + # #c = shell_createContext() #c.cCLI = cli_createContext() diff --git a/v4/memory_Context.py b/v4/memory_Context.py index f2359e7..e77dfeb 100644 --- a/v4/memory_Context.py +++ b/v4/memory_Context.py @@ -1,5 +1,6 @@ class memory_Context: def __init__(self): + self.didLaunch = False self.hiddenItems = [] self.input = "" self.mismatchedItems = []