Skip to content

Commit

Permalink
extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed Nov 29, 2015
1 parent c93f54e commit 26ea215
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hooks/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

__version__ = "0.2.0-pre"
45 changes: 45 additions & 0 deletions hooks/extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
import os


__all__ = [
'autodiscover',
'apps',
'urls'
]

apps = []
urls = []


def autodiscover(import_path, app_config='Extension'):
# Relative path to the extension's package in
# dot notation such as 'my_app.extensions'

global apps, urls

extensions_dir = os.path.join(os.getcwd(), *import_path.split('.'))
apps_ = []
urls_ = []

for app in os.listdir(extensions_dir):
app_import_path = '.'.join((import_path, app))

if not os.path.isfile(os.path.join(extensions_dir, app, 'apps.py')):
continue

apps_.append(
'.'.join((app_import_path, 'apps', app_config))
)

if not os.path.isfile(os.path.join(extensions_dir, app, 'urls.py')):
continue

urls_.append(
'.'.join((app_import_path, 'urls'))
)

apps = apps_
urls = urls_

0 comments on commit 26ea215

Please sign in to comment.