Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBurchLog committed Aug 27, 2024
1 parent a3d2d56 commit 62b234d
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions brewtils/rest/publish_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,16 @@ def _get_parent_for_request(self):
return Request(id=str(parent.id))

def register_command(self, topic: str, cmd) -> Topic:
"""Register a command to subscribe to the topic provided. The subscriber is marked as GENERATED, and will be
pruned after the system shuts down
"""Register a command to subscribe to the topic provided. The subscriber is
marked as GENERATED, and will be pruned after the system shuts down
Args:
topic (str): Topic for the command to subscribe to
cmd (str, function): Command to register
Raises:
BrewtilsException: If function is provided, it must be an annotated function. Only supports running plugins
BrewtilsException: If function is provided, it must be an annotated
function. Only supports running plugins
Returns:
Topic: Updated Topic Model
Expand All @@ -179,15 +180,21 @@ def register_command(self, topic: str, cmd) -> Topic:
and brewtils.plugin.CONFIG.namespace
):
raise BrewtilsException(
"Unable to identify Configuration for Plugin, only running Plugins can register commands"
(
"Unable to identify Configuration for Plugin, "
"only running Plugins can register commands"
)
)

if type(cmd) == str:
if isinstance(cmd, str):
command_name = cmd
else:
if not hasattr(cmd, "_command"):
raise BrewtilsException(
f"Attempted to register command {getattr(cmd, '__name__', 'MISSING FUNC NAME')} that is not an annotated command"
(
f"Attempted to register command {getattr(cmd, '__name__', 'MISSING FUNC NAME')} "
"that is not an annotated command"
)
)
command_name = cmd._command.name

Expand All @@ -212,7 +219,8 @@ def unregister_command(self, topic: str, cmd) -> Topic:
cmd (str, function): Command to unregister
Raises:
BrewtilsException: If function is provided, it must be an annotated function. Only supports running plugins
BrewtilsException: If function is provided, it must be
an annotated function. Only supports running plugins
Returns:
Topic: Updated Topic Model
Expand All @@ -225,15 +233,21 @@ def unregister_command(self, topic: str, cmd) -> Topic:
and brewtils.plugin.CONFIG.namespace
):
raise BrewtilsException(
"Unable to identify Configuration for Plugin, only running Plugins can unregister commands"
(
"Unable to identify Configuration for Plugin, only "
"running Plugins can unregister commands"
)
)

if type(cmd) == str:
if isinstance(cmd, str):
command_name = cmd
else:
if not hasattr(cmd, "_command"):
raise BrewtilsException(
f"Attempted to register command {getattr(cmd, '__name__', 'MISSING FUNC NAME')} that is not an annotated command"
(
f"Attempted to register command {getattr(cmd, '__name__', 'MISSING FUNC NAME')} "
"that is not an annotated command"
)
)
command_name = cmd._command.name

Expand Down

0 comments on commit 62b234d

Please sign in to comment.