@@ -16,13 +16,14 @@ import shlex
1616import stat
1717import errno
1818
19- from packaging import version
19+ from pkg_resources import packaging # type: ignore
2020
2121from cmd2 import Cmd
2222from cmd2 import __version__ as cmd2_version
2323# XXX: In cmd2 versions < 1.0.1, we'll get SystemExit(2) instead of
2424# Cmd2ArgparseError
25- if version .parse (cmd2_version ) >= version .parse ("1.0.1" ):
25+ Version = packaging .version .Version
26+ if Version (cmd2_version ) >= Version ("1.0.1" ):
2627 from cmd2 .exceptions import Cmd2ArgparseError
2728else :
2829 # HACK: so that we don't have check for version everywhere
@@ -1700,11 +1701,11 @@ def read_shell_conf(shell, shell_conf_file):
17001701
17011702 sec = 'cephfs-shell'
17021703 opts = []
1703- if version . parse (cmd2_version ) >= version . parse ("0.10.0" ):
1704+ if Version (cmd2_version ) >= Version ("0.10.0" ):
17041705 for attr in shell .settables .keys ():
17051706 opts .append (attr )
17061707 else :
1707- if version . parse (cmd2_version ) <= version . parse ("0.9.13" ):
1708+ if Version (cmd2_version ) <= Version ("0.9.13" ):
17081709 # hardcoding options for 0.7.9 because -
17091710 # 1. we use cmd2 v0.7.9 with teuthology and
17101711 # 2. there's no way distinguish between a shell setting and shell
@@ -1713,7 +1714,7 @@ def read_shell_conf(shell, shell_conf_file):
17131714 'continuation_prompt' , 'debug' , 'echo' , 'editor' ,
17141715 'feedback_to_output' , 'locals_in_py' , 'prompt' , 'quiet' ,
17151716 'timing' ]
1716- elif version . parse (cmd2_version ) >= version . parse ("0.9.23" ):
1717+ elif Version (cmd2_version ) >= Version ("0.9.23" ):
17171718 opts .append ('allow_style' )
17181719 # no equivalent option was defined by cmd2.
17191720 else :
@@ -1768,7 +1769,7 @@ def manage_args():
17681769 args .exe_and_quit = False # Execute and quit, don't launch the shell.
17691770
17701771 if args .batch :
1771- if version . parse (cmd2_version ) <= version . parse ("0.9.13" ):
1772+ if Version (cmd2_version ) <= Version ("0.9.13" ):
17721773 args .commands = ['load ' + args .batch , ',quit' ]
17731774 else :
17741775 args .commands = ['run_script ' + args .batch , ',quit' ]
@@ -1813,7 +1814,7 @@ def execute_cmds_and_quit(args):
18131814 # value to indicate whether the execution of the commands should stop, but
18141815 # since 0.9.7 it returns the return value of do_* methods only if it's
18151816 # not None. When it is None it returns False instead of None.
1816- if version . parse (cmd2_version ) <= version . parse ("0.9.6" ):
1817+ if Version (cmd2_version ) <= Version ("0.9.6" ):
18171818 stop_exec_val = None
18181819 else :
18191820 stop_exec_val = False
0 commit comments