diff options
| author | Stephen Finucane <sfinucan@redhat.com> | 2021-10-08 18:06:11 +0100 |
|---|---|---|
| committer | Stephen Finucane <sfinucan@redhat.com> | 2021-10-21 17:14:45 +0100 |
| commit | 30612bf62295720a21d39c4f589cfcefb7a86a2f (patch) | |
| tree | a3133b6071a62e32dbb5c899f918cd2827ff208a /openstackclient/common | |
| parent | a797c9d2a351fd87d2f8075bbf7180fc6b202d92 (diff) | |
| download | python-openstackclient-30612bf62295720a21d39c4f589cfcefb7a86a2f.tar.gz | |
Remove 'get_osc_show_columns_for_sdk_resource' duplicates
There were a number of 'get_osc_show_columns_for_sdk_resource' defined
in-tree. However, osc-lib has provided this method for some time (since
2.2.0, June 2020 [1] - our minimum version is currently 2.3.0) so
there's no need to provide our own copies. Remove them.
[1] https://github.com/openstack/osc-lib/commit/29a0c5a5
Change-Id: I25695f4f9a379dd691b7eaa1e3247164668ae77e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/sdk_utils.py | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/openstackclient/common/sdk_utils.py b/openstackclient/common/sdk_utils.py deleted file mode 100644 index af9c74f9..00000000 --- a/openstackclient/common/sdk_utils.py +++ /dev/null @@ -1,58 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -def get_osc_show_columns_for_sdk_resource( - sdk_resource, - osc_column_map, - invisible_columns=None -): - """Get and filter the display and attribute columns for an SDK resource. - - Common utility function for preparing the output of an OSC show command. - Some of the columns may need to get renamed, others made invisible. - - :param sdk_resource: An SDK resource - :param osc_column_map: A hash of mappings for display column names - :param invisible_columns: A list of invisible column names - - :returns: Two tuples containing the names of the display and attribute - columns - """ - - if getattr(sdk_resource, 'allow_get', None) is not None: - resource_dict = sdk_resource.to_dict( - body=True, headers=False, ignore_none=False) - else: - resource_dict = sdk_resource - - # Build the OSC column names to display for the SDK resource. - attr_map = {} - display_columns = list(resource_dict.keys()) - invisible_columns = [] if invisible_columns is None else invisible_columns - for col_name in invisible_columns: - if col_name in display_columns: - display_columns.remove(col_name) - for sdk_attr, osc_attr in osc_column_map.items(): - if sdk_attr in display_columns: - attr_map[osc_attr] = sdk_attr - display_columns.remove(sdk_attr) - if osc_attr not in display_columns: - display_columns.append(osc_attr) - sorted_display_columns = sorted(display_columns) - - # Build the SDK attribute names for the OSC column names. - attr_columns = [] - for column in sorted_display_columns: - new_column = attr_map[column] if column in attr_map else column - attr_columns.append(new_column) - return tuple(sorted_display_columns), tuple(attr_columns) |
