summaryrefslogtreecommitdiffstats
path: root/openstack/common/importutils.py
Commit message (Collapse)AuthorAgeFilesLines
* Enable hacking H404 test.Dina Belova2013-06-111-2/+3
| | | | | | H404 - multi line docstring should start with a summary. Change-Id: I2099e1ee81ff9657f7a07401b8e8f3327d03bdbd
* Enable hacking H402 testSergey Lukjanov2013-06-031-1/+1
| | | | | | H402 one line docstring needs punctuation Change-Id: Ie848453cace318d8310cdf0234c512f4c1121119
* Fix Copyright Headers - Rename LLC to FoundationDavanum Srinivas2013-03-111-1/+1
| | | | | | One code change, rest are in headers Change-Id: I73f59681358629e1ad74e49d3d3ca13fcb5c2eb1
* Implement importutils.try_import.Dan Prince2013-01-141-0/+8
| | | | | | | | | | | | | | | | | | | | Adds a new (simple) importutils.try_import function which can return a module name or a default (by default this is None). This should help clean up some of our try: import foo except... blocks in modules. This commit also drops the dependency on python-extras which is no longer needed. Fixes LP Bug #1099501. Change-Id: I8591f79983bdad67a50d1aaae6dce8428dfce084
* Make project pyflakes clean.Monty Taylor2012-11-281-1/+1
| | | | | | | | | | | | | Added both a tox test-env for pyflakes and fixed the current pyflakes errors. This did actually fix a couple of bugs. The CI team has started using pyflakes on its projects and also has started using oslo for things, so ignoring pyflakes warnings on the oslo code was starting to get old. However, additionally, pyflakes is pretty solid, so we should maybe consider gating on it across the board. (% locals() is the biggest thing that we do that it doesn't like) Change-Id: Iac1ca62db301892b7863711162fcbc74807eb24f
* Don't trap then re-raise ImportError.Monty Taylor2012-08-171-1/+1
| | | | | | | | | When we catch ImportError, print a message, and then raise a new ImportError, we lose sane ability to read the traceback, and we gain nothing. Raising a new ImportError on Attribute or Value error is helpful, given the context in which we are working. Change-Id: I52f61405e63535bcc745c9d350aa0dfbae36a8ac
* Improve exception from importutils.import_class().Russell Bryant2012-06-191-1/+3
| | | | | | | | | The ImportError raised by import_class() attempted to tell you what the original error was by just doing str() on the original exception. Sometimes that's helpful, but sometimes a full traceback is needed. This patch includes a traceback for debugging purposes. Change-Id: I00cefb9ebf9d6a71ef491204d81765e30e7941f6
* Merge "add import_object_ns function"Jenkins2012-06-181-0/+13
|\
| * add import_object_ns functionSean Dague2012-06-141-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | To support bp:virt-driver-cleanup, there is a desire to have shorter driver strings (i.e. libvirt.LibvirtDriver instead of nova.virt.libvirt.LibvirtDriver). One way to support this is with a new import_object variant that takes a namespace to load from. If the code fails to load the driver in the prefered namespace it will also try loading the full driver path, before throwing an exception. Change-Id: Ib97c92f38685ca89f29890f8015fc413acc744f8
* | Update common code to support pep 1.3.Gary Kotton2012-06-181-1/+1
|/ | | | | | bug 1014216 Change-Id: I3f8fa2e11c9d3f3d34fb20f65ce886bb9c94463d
* Remove common.exception from common.importutils.Russell Bryant2012-05-021-3/+1
| | | | | | | | This patch removes the usage of common.exception from common.importutils. Instead of raising exception.NotFound() from importutils.import_class(), just use the built-in ImportError. Change-Id: I95e84908d1f80c5ca3bbac049eda8faa64212ae0
* Update exception from importutils.import_class().Russell Bryant2012-04-281-2/+3
| | | | | | | | | | Update the message included in the exception from importutils.import_class() to include what the inner exception was. This is quite helpful as the real error may not have been that the class was not found. It may have failed to import the module that contains that class, and it's nice to know that and why that happened. Change-Id: I085864d230b46adce8921e362f058f9421a5a674
* Change behavior in utils.import_object().Russell Bryant2012-04-111-0/+45
Fix bug 972859. Prior to this patch, utils.import_object(foo) and utils.import_class(foo) would return the same thing if foo was the path to a class. This patch changes utils.import_object() to return an instance of the class, instead, also allowing you to pass in arguments to the constructor. This patch also removes the odd behavior of import_object() to be able to also import a module. Instead, a new function import_module() has been added. Finally, the three import helpers have been moved to a new module, importutils. Change-Id: Ia2ea64c965692f8c3a29adec332dd93a83980070