Skip to content

Commit 53f13e4

Browse files
committed
Starting directory support
1 parent 2ef6064 commit 53f13e4

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

README.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ We can have an object of that class just with:
5757
5858
Simple and easy.
5959

60+
API
61+
---
62+
63+
This is a simple module with a simple API. It just contains one class, :code:`PluginLoader`, with these public methods:
64+
65+
:code:`load_file(filename, onlyif=None)`
66+
////////////////////////////////////////
67+
68+
Parameters:
69+
70+
- ``filename``: File name to be loaded.
71+
- ``onlyif``: Value or function that will be called with each class found. It will skip the plugin if this function returns :code:`False`.
72+
73+
74+
:code:`load_directory(path, onlyif=None)`
75+
////////////////////////////////////////
76+
77+
TO BE DONE
6078

6179
License
6280
=======

pluginloader/loader.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def load_file(self, filename, onlyif=None):
2424
if (self._apply_condition(onlyif, name, clazz)):
2525
self.plugins[name] = PluginFactory(clazz)
2626

27+
def load_directory(self, path):
28+
pass
29+
2730
def _apply_condition(self, condition, *args, **kwargs):
2831
if callable(condition):
2932
return condition(*args, **kwargs)

tests/integration/test_directory_loader.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
from pluginloader.loader import PluginLoader
77

88

9-
@unittest.skip('Not ready yet')
109
class plugins_in_directory(unittest.TestCase):
1110
def setUp(self):
1211
self.plugin_dir = tempfile.mkdtemp()
1312

1413
def tearDown(self):
1514
shutil.rmtree(self.plugin_dir)
1615

17-
def test_load_file(self):
16+
def test_empty_directory(self):
1817
sut = PluginLoader()
1918

20-
sut.load_directory()
19+
sut.load_directory(self.plugin_dir)
20+
21+
self.assertEqual({}, sut.plugins)

0 commit comments

Comments
 (0)