Remove logic for Python < 3

... because Python 2 support was removed long ago.

Change-Id: Iebf18019a2a40176c430286e8d678879d9fef63f
This commit is contained in:
Takashi Kajinami 2024-09-03 16:38:03 +09:00
parent 65b99bdf1a
commit 59fb4a2579
2 changed files with 5 additions and 20 deletions

View File

@ -747,11 +747,7 @@ class OpenStackHelpFormatter(argparse.HelpFormatter):
def main(): def main():
try: try:
if sys.version_info >= (3, 0): OpenStackTroveShell().main(sys.argv[1:])
OpenStackTroveShell().main(sys.argv[1:])
else:
OpenStackTroveShell().main(map(encodeutils.safe_decode,
sys.argv[1:]))
except KeyboardInterrupt: except KeyboardInterrupt:
print(_("... terminating trove client"), file=sys.stderr) print(_("... terminating trove client"), file=sys.stderr)
sys.exit(130) sys.exit(130)

View File

@ -17,7 +17,6 @@
import base64 import base64
import json import json
import os import os
import sys
import uuid import uuid
from openstackclient.identity import common as identity_common from openstackclient.identity import common as identity_common
@ -135,14 +134,6 @@ def _output_override(objs, print_as):
raise BaseException('No valid output override') raise BaseException('No valid output override')
def _print(pt, order):
if sys.version_info >= (3, 0):
print(pt.get_string(sortby=order))
else:
print(encodeutils.safe_encode(pt.get_string(sortby=order)))
def print_list(objs, fields, formatters={}, order_by=None, obj_is_dict=False, def print_list(objs, fields, formatters={}, order_by=None, obj_is_dict=False,
labels={}): labels={}):
try: try:
@ -194,19 +185,19 @@ def print_list(objs, fields, formatters={}, order_by=None, obj_is_dict=False,
if not order_by: if not order_by:
order_by = fields[0] order_by = fields[0]
order_by = labels[order_by] order_by = labels[order_by]
_print(pt, order_by) print(pt.get_string(sortby=order_by))
def print_dict(d, property="Property"): def print_dict(d, key="Property"):
try: try:
_output_override(d, 'dict') _output_override(d, 'dict')
return return
except BaseException: except BaseException:
pass pass
pt = prettytable.PrettyTable([property, 'Value'], caching=False) pt = prettytable.PrettyTable([key, 'Value'], caching=False)
pt.align = 'l' pt.align = 'l'
[pt.add_row(list(r)) for r in d.items()] [pt.add_row(list(r)) for r in d.items()]
_print(pt, property) print(pt.get_string(sortby=key))
def get_resource_id(manager, id_or_name): def get_resource_id(manager, id_or_name):
@ -252,8 +243,6 @@ def find_resource(manager, name_or_id):
# Related to bug/1740015. # Related to bug/1740015.
if isinstance(name_or_id, int): if isinstance(name_or_id, int):
name_or_id = str(name_or_id) name_or_id = str(name_or_id)
elif sys.version_info <= (3, 0):
name_or_id = encodeutils.safe_decode(name_or_id)
try: try:
return manager.get(name_or_id) return manager.get(name_or_id)