Multi-module and/or multi-package projects

Overview

Ooze will happily work with complex projects that have multiple modules and packages. The only stipulation to this is that Ooze has to be aware of the module and/or packages. What this means that if you don’t import a module or package, Ooze won’t know about it.

For example, you may have module file_reader.py that has the following code:

1import ooze
2
3
4@ooze.provide
5class FileReader(datafile):
6
7    def read(self):
8        with open(datafile) as infile:
9            return infile.read()

You may also have a module named main.py that has the following code:

 1import ooze
 2import file_reader          # You gotta import this or Ooze won't see it.
 3
 4ooze.provide('datafile')('/tmp/stuff.txt')
 5
 6def main_func(filereader):    # Ooze will figure out how to inject even
 7    print(filereader.read())  # though it's in another module.
 8
 9if __name__ == '__main__':
10    ooze.run(main_func)

When you run main.py, main_func will have the FileReader injected into it as you’d expect, but only if the import file_reader line is present. If you were to fail to import the file_reader module, Ooze wouldn’t have an opportunity to add the FileReader instance to the dependency graph.