Clean up warnings and move jinja_env onto base

This commit is contained in:
Eric Holscher 2015-06-10 11:01:06 -07:00
parent 2dcb0ca200
commit a94e3d8c60
3 changed files with 9 additions and 8 deletions

View File

@ -16,8 +16,10 @@ class AutoAPIBase(object):
language = 'base'
type = 'base'
def __init__(self, obj):
def __init__(self, obj, jinja_env=None):
self.obj = obj
if jinja_env:
self.jinja_env = jinja_env
def render(self, ctx=None):
if not ctx:

View File

@ -27,9 +27,9 @@ class JavaScriptDomain(AutoAPIDomain):
parsed_data = json.loads(subprocess.check_output(['jsdoc', '-X', path]))
return parsed_data
except IOError:
print Warning('Error reading file: {0}'.format(path))
self.app.warn('Error reading file: {0}'.format(path))
except TypeError:
print Warning('Error reading file: {0}'.format(path))
self.app.warn('Error reading file: {0}'.format(path))
return None
def map(self):

View File

@ -26,9 +26,9 @@ class PythonDomain(AutoAPIDomain):
parsed_data = parsed(path)
return parsed_data
except IOError:
print Warning('Error reading file: {0}'.format(path))
self.app.warn('Error reading file: {0}'.format(path))
except TypeError:
print Warning('Error reading file: {0}'.format(path))
self.app.warn('Error reading file: {0}'.format(path))
return None
def create_class(self, data):
@ -64,10 +64,9 @@ class PythonBase(AutoAPIBase):
language = 'python'
def __init__(self, obj, jinja_env):
super(PythonBase, self).__init__(obj)
def __init__(self, obj, **kwargs):
super(PythonBase, self).__init__(obj, **kwargs)
self.jinja_env = jinja_env
# Always exist
self.id = obj['fullname']
self.name = self.obj.get('fullname', self.id)