Skip to content

Commit

Permalink
- Encoding declararion was blowing up the plugin ClassLoader. The en…
Browse files Browse the repository at this point in the history
…coding declaration string is now stripped if present.
  • Loading branch information
lliendo committed Jan 3, 2016
1 parent 103bb84 commit 9595f23
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion radar/class_loader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ClassLoader(object):
to load unknown classes dynamically at run-time.
"""

ENCODING_DECLARATION = '# -*- coding: utf-8 -*-'

def __init__(self, module_path):
self._module_path = module_path
module_search_path.append(module_path)
Expand All @@ -50,7 +52,7 @@ def _get_class_names(self, filename):

try:
with open(filename) as fd:
parsed_source = ast_parse(fd.read())
parsed_source = ast_parse(fd.read().strip(self.ENCODING_DECLARATION))
class_names = [n.name for n in ast_walk(parsed_source) if isinstance(n, ClassDef)]
except IOError as e:
raise ClassLoaderError('Error - Couldn\'t open : \'{:}\'. Reason : {:}.'.format(filename, e.strerror))
Expand Down

0 comments on commit 9595f23

Please sign in to comment.