From 14952a9614419e835428770f46a0968addab559e Mon Sep 17 00:00:00 2001 From: vhag Date: Tue, 8 Aug 2017 11:45:03 +0200 Subject: [PATCH] Add function that returns a list of all functions in their respective category --- pygorithm/data_structures/__init__.py | 1 + pygorithm/data_structures/modules.py | 14 ++++++++++++++ pygorithm/searching/__init__.py | 1 + pygorithm/searching/modules.py | 14 ++++++++++++++ pygorithm/sorting/modules.py | 14 ++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 pygorithm/data_structures/modules.py create mode 100644 pygorithm/searching/modules.py create mode 100644 pygorithm/sorting/modules.py diff --git a/pygorithm/data_structures/__init__.py b/pygorithm/data_structures/__init__.py index e69de29..05039ea 100644 --- a/pygorithm/data_structures/__init__.py +++ b/pygorithm/data_structures/__init__.py @@ -0,0 +1 @@ +from . modules import modules diff --git a/pygorithm/data_structures/modules.py b/pygorithm/data_structures/modules.py new file mode 100644 index 0000000..149924c --- /dev/null +++ b/pygorithm/data_structures/modules.py @@ -0,0 +1,14 @@ +import pkgutil +def modules(): + """ + Find all functions in pygorithm.data_structures + """ + import pygorithm.data_structures + package = pygorithm.data_structures + modules = [] + for importer, modname, ispkg in pkgutil.iter_modules(package.__path__): + modules.append(modname) + modules.remove('modules') + modules.sort() + return modules + diff --git a/pygorithm/searching/__init__.py b/pygorithm/searching/__init__.py index e69de29..05039ea 100644 --- a/pygorithm/searching/__init__.py +++ b/pygorithm/searching/__init__.py @@ -0,0 +1 @@ +from . modules import modules diff --git a/pygorithm/searching/modules.py b/pygorithm/searching/modules.py new file mode 100644 index 0000000..abcd1fa --- /dev/null +++ b/pygorithm/searching/modules.py @@ -0,0 +1,14 @@ +import pkgutil +def modules(): + """ + Find all functions in pygorithm.searching + """ + import pygorithm.searching + package = pygorithm.searching + modules = [] + for importer, modname, ispkg in pkgutil.iter_modules(package.__path__): + modules.append(modname) + modules.remove('modules') + modules.sort() + return modules + diff --git a/pygorithm/sorting/modules.py b/pygorithm/sorting/modules.py new file mode 100644 index 0000000..55f60c5 --- /dev/null +++ b/pygorithm/sorting/modules.py @@ -0,0 +1,14 @@ +import pkgutil +def modules(): + """ + Find all functions in pygorithm.sorting + """ + import pygorithm.sorting + package = pygorithm.sorting + modules = [] + for importer, modname, ispkg in pkgutil.iter_modules(package.__path__): + modules.append(modname) + modules.remove('modules') + modules.sort() + return modules +