summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-08-01 03:08:22 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-08-01 03:08:22 -0400
commit519283d460e4797ca1376348b63f737749ccc016 (patch)
tree519cb8890789f3f5cec96ed99c281ece1d4f5d90 /cmd2/utils.py
parentbc559df2afcc51d1804e5d068d7e2c57bc4f72af (diff)
downloadcmd2-git-519283d460e4797ca1376348b63f737749ccc016.tar.gz
Added matches_sorted member to support custom sorting order of tab-completion matches
Made all sorting alphabetical Fixed case where extra slash was printing when tab completing users on Windows
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index d03e7f6f..d8afd922 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -144,3 +144,16 @@ def is_text_file(file_path: str) -> bool:
pass
return valid_text_file
+
+
+def remove_duplicates(list_to_prune: List) -> List:
+ """
+ Removes duplicates from a list while preserving order of the items
+ :param list_to_prune: the list being pruned of duplicates
+ :return: The pruned list
+ """
+ temp_dict = collections.OrderedDict()
+ for item in list_to_prune:
+ temp_dict[item] = None
+
+ return list(temp_dict.keys())