-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update events to emit model/session objects #1214
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,6 +337,7 @@ def __init__(self, cli_name, session, service_name=None): | |
else: | ||
self._service_name = service_name | ||
self._lineage = [self] | ||
self._service_model = None | ||
|
||
@property | ||
def name(self): | ||
|
@@ -368,6 +369,11 @@ def _get_service_object(self): | |
self._service_object = self.session.get_service(self._service_name) | ||
return self._service_object | ||
|
||
def _get_service_model(self): | ||
if self._service_model is None: | ||
self._service_model = self.session.get_service_model(self._service_name) | ||
return self._service_model | ||
|
||
def __call__(self, args, parsed_globals): | ||
# Once we know we're trying to call a service for this operation | ||
# we can go ahead and create the parser for it. We | ||
|
@@ -380,12 +386,16 @@ def __call__(self, args, parsed_globals): | |
def _create_command_table(self): | ||
command_table = OrderedDict() | ||
service_object = self._get_service_object() | ||
service_model = self._get_service_model() | ||
for operation_object in service_object.operations: | ||
cli_name = xform_name(operation_object.name, '-') | ||
command_table[cli_name] = ServiceOperation( | ||
name=cli_name, | ||
parent_name=self._name, | ||
session=self.session, | ||
operation_object=operation_object, | ||
operation_model=service_model.operation_model( | ||
operation_object.name), | ||
operation_caller=CLIOperationCaller(self.session), | ||
service_object=service_object) | ||
self.session.emit('building-command-table.%s' % self._name, | ||
|
@@ -433,7 +443,7 @@ class ServiceOperation(object): | |
DEFAULT_ARG_CLASS = CLIArgument | ||
|
||
def __init__(self, name, parent_name, operation_object, operation_caller, | ||
service_object): | ||
service_object, operation_model, session): | ||
""" | ||
|
||
:type name: str | ||
|
@@ -462,6 +472,8 @@ def __init__(self, name, parent_name, operation_object, operation_caller, | |
self._operation_caller = operation_caller | ||
self._service_object = service_object | ||
self._lineage = [self] | ||
self._operation_model = operation_model | ||
self._session = session | ||
|
||
@property | ||
def name(self): | ||
|
@@ -598,6 +610,9 @@ def _create_argument_table(self): | |
self._emit('building-argument-table.%s.%s' % (self._parent_name, | ||
self._name), | ||
operation=self._operation_object, | ||
operation_model=self._operation_model, | ||
session=self._session, | ||
command=self, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I am in favor of adding the command object to the event. But could we name it |
||
argument_table=argument_table) | ||
return argument_table | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any other way we can pull the
name
out (other than from operation objects)? That way it would be deleting arguments from calls and constructors when we do the final purge of operation objects.