Skip to content

Commit

Permalink
renamed context to canape
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy committed Jan 31, 2024
1 parent ec3c59c commit 385299c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/pycanape/actionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ActionBuilder:
CANape in modal mode. What this
means isn't clearly documented.
context: Optional[CANape]
canape: Optional[CANape]
This attribute is special and is
used only to allow the inner CANape
connection to be used within a
Expand All @@ -49,13 +49,13 @@ class ActionBuilder:
project_path: str
modal_mode: bool

context: Optional[CANape]
canape: Optional[CANape]

def __init__(self, _action: CanapeAction = lambda x: x):
self._action = _action

def __enter__(self):
self.context = CANape(self.project_path, self.modal_mode)
self.canape = CANape(self.project_path, self.modal_mode)

def __exit__(self, primus, secundus, tertius):
# It is apropriate to ignore the below line for
Expand All @@ -64,22 +64,22 @@ def __exit__(self, primus, secundus, tertius):
# is not None. It is notable that the user can
# screw around but I don't need to worry about
# that.
self.context.exit(self.close_canape) # type: ignore
self.canape.exit(self.close_canape) # type: ignore

def __call__(self, context: Optional[CANape] = None) -> CANape:
def __call__(self, canape: Optional[CANape] = None) -> CANape:
"""Using this wrapper will lock
the application only for the
duration of this function.
This function ultimately returns
a closed CANape object IE. unusable."""
if context is None:
canape = CANape(self.project_path, self.modal_mode)
self._action(canape)
if canape is None:
self.canape = CANape(self.project_path, self.modal_mode)
self._action(self.canape)
canape.exit(self.close_canape)
return canape
else:
self._action(context)
return context
self._action(canape)
return canape

def also(self, next_action: CanapeAction) -> "ActionBuilder":
"""This function allows the chaining of
Expand Down

0 comments on commit 385299c

Please sign in to comment.