Mercurial > hg > autobot
comparison autobot/projects/__init__.py @ 59:e66165f2f31b
complete automagic imports
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 10 Jan 2011 22:40:18 -0800 |
parents | f586e28ff3d7 |
children | f8dccf3377d9 |
comparison
equal
deleted
inserted
replaced
58:008404759e4f | 59:e66165f2f31b |
---|---|
8 * firebug [TODO] | 8 * firebug [TODO] |
9 * jetpack thing [TODO] | 9 * jetpack thing [TODO] |
10 * autobot [TODO] | 10 * autobot [TODO] |
11 """ | 11 """ |
12 | 12 |
13 import imp | |
13 import os | 14 import os |
14 | 15 from buildbot.process.factory import BuildFactory |
15 from logparser import TestLogParserFactory | 16 from logparser import TestLogParserFactory |
16 from mozmill import TestMozmillFactory | 17 from mozmill import TestMozmillFactory |
17 # TODO: import these automagically: | 18 |
18 # requires non-zipped eggs | 19 # available factories:: |
20 # import these automagically: requires non-zipped eggs | |
21 factories = {} | |
22 descriptions = {} | |
19 here = os.path.dirname(os.path.abspath(__file__)) | 23 here = os.path.dirname(os.path.abspath(__file__)) |
20 packages = [os.path.join(here, path) | 24 packages = [os.path.join(here, path) |
21 for path in os.listdir(here) | 25 for path in os.listdir(here) |
22 if os.path.isdir(os.path.join(here, path))] | 26 if os.path.isdir(os.path.join(here, path))] |
23 packages = [package for package in packages | 27 packages = [os.path.basename(package) for package in packages |
24 if os.path.exists(os.path.join(package, '__init__.py'))] | 28 if os.path.exists(os.path.join(package, '__init__.py'))] |
29 for package in packages: | |
30 try: | |
31 module = imp.load_package('autobot.projects.'+package, imp.find_module(package, [here])[1]) | |
32 except: | |
33 continue | |
34 for attr in dir(module): | |
35 try: | |
36 _obj = getattr(module, attr) | |
37 if issubclass(_obj, BuildFactory) and _obj.__module__.startswith('autobot.projects.'): | |
38 factories[package] = _obj | |
39 descriptions[package] = (getattr(_obj, '__doc__', attr) or attr).strip() | |
40 except TypeError: | |
41 continue | |
25 | 42 |
26 # available factories | |
27 factories = {'logparser': TestLogParserFactory, | |
28 'mozmill': TestMozmillFactory } |