Skip to content

Commit

Permalink
Clean up util logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Jan 26, 2018
1 parent 328e65e commit d30dd94
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions chatterbot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ def validate_adapter_class(validate_class, adapter_class):

# If a dictionary was passed in, check if it has an import_path attribute
if isinstance(validate_class, dict):
origional_data = validate_class.copy()
validate_class = validate_class.get('import_path')

if not validate_class:
if 'import_path' not in validate_class:
raise Adapter.InvalidAdapterTypeException(
'The dictionary {} must contain a value for "import_path"'.format(
str(origional_data)
str(validate_class)
)
)

# Set the class to the import path for the next check
validate_class = validate_class.get('import_path')

if not issubclass(import_module(validate_class), adapter_class):
raise Adapter.InvalidAdapterTypeException(
'{} must be a subclass of {}'.format(
Expand Down

0 comments on commit d30dd94

Please sign in to comment.