summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
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())