From f6bb5b2b776dd7aaca52bf7ba0d48ca571bb167e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 27 Nov 2012 14:33:23 -0800 Subject: [PATCH] raise InvalidSpec if no colon --- edbob/exceptions.py | 6 ++++++ edbob/modules.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/edbob/exceptions.py b/edbob/exceptions.py index a5a802e..58da82f 100644 --- a/edbob/exceptions.py +++ b/edbob/exceptions.py @@ -73,6 +73,12 @@ class LoadSpecError(Exception): return None +class InvalidSpec(LoadSpecError): + + def specifics(self): + return "invalid spec" + + class ModuleMissingAttribute(LoadSpecError): """ Raised during :func:`edbob.load_spec()` when the module imported okay but diff --git a/edbob/modules.py b/edbob/modules.py index e3d4287..2cdf59b 100644 --- a/edbob/modules.py +++ b/edbob/modules.py @@ -82,6 +82,9 @@ def load_spec(spec): necessary. """ + if spec.count(':') != 1: + raise exceptions.InvalidSpec(spec) + module_path, obj = spec.split(':') module = import_module_path(module_path) try: