Merge pull request #174 from stephane-martin/explicit_absolute_relative_imports
systematic use of `from __future__ import absolute_import`
This commit is contained in:
commit
87827ca156
|
@ -1,16 +1,19 @@
|
||||||
import functools
|
from __future__ import absolute_import
|
||||||
import sys
|
|
||||||
|
|
||||||
|
import sys
|
||||||
# Set default encoding to UTF-8
|
# Set default encoding to UTF-8
|
||||||
reload(sys)
|
reload(sys)
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
sys.setdefaultencoding('utf-8')
|
sys.setdefaultencoding('utf-8')
|
||||||
|
|
||||||
|
import functools
|
||||||
import base64
|
import base64
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import httplib
|
|
||||||
import traceback
|
import traceback
|
||||||
|
import six.moves.http_client as httplib
|
||||||
|
from functools import update_wrapper
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from flask import Flask, request, render_template, url_for, redirect, g
|
from flask import Flask, request, render_template, url_for, redirect, g
|
||||||
from flask_cache import Cache
|
from flask_cache import Cache
|
||||||
|
@ -18,16 +21,15 @@ from flask_login import LoginManager, current_user
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from flask_assets import Environment, Bundle
|
from flask_assets import Environment, Bundle
|
||||||
from flask_ldap_login import LDAPLoginManager
|
from flask_ldap_login import LDAPLoginManager
|
||||||
from functools import update_wrapper
|
|
||||||
from werkzeug.routing import BaseConverter
|
from werkzeug.routing import BaseConverter
|
||||||
from werkzeug.exceptions import HTTPException
|
from werkzeug.exceptions import HTTPException
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
|
||||||
from .modules.search.models import Search
|
from realms.modules.search.models import Search
|
||||||
from .lib.util import to_canonical, remove_ext, mkdir_safe, gravatar_url, to_dict
|
from realms.lib.util import to_canonical, remove_ext, mkdir_safe, gravatar_url, to_dict
|
||||||
from .lib.hook import HookModelMeta, HookMixin
|
from realms.lib.hook import HookModelMeta, HookMixin
|
||||||
from .lib.util import is_su, in_virtualenv
|
from realms.lib.util import is_su, in_virtualenv
|
||||||
from .version import __version__
|
from realms.version import __version__
|
||||||
|
|
||||||
|
|
||||||
class Application(Flask):
|
class Application(Flask):
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
from realms import config, create_app, db, __version__, cli, cache
|
from __future__ import absolute_import
|
||||||
from realms.lib.util import random_string, in_virtualenv, green, yellow, red
|
|
||||||
from subprocess import call, Popen
|
|
||||||
from multiprocessing import cpu_count
|
|
||||||
import click
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import pip
|
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from subprocess import call, Popen
|
||||||
|
from multiprocessing import cpu_count
|
||||||
|
|
||||||
|
import click
|
||||||
|
import pip
|
||||||
|
|
||||||
|
from realms import config, create_app, db, __version__, cli, cache
|
||||||
|
from realms.lib.util import random_string, in_virtualenv, green, yellow, red
|
||||||
|
|
||||||
|
|
||||||
config = config.conf
|
config = config.conf
|
||||||
|
|
||||||
|
|
||||||
# called to discover commands in modules
|
# called to discover commands in modules
|
||||||
app = create_app()
|
app = create_app()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from urlparse import urlparse
|
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
from six.moves.urllib.parse import urlparse
|
||||||
|
|
||||||
from realms.lib.util import in_vagrant
|
from realms.lib.util import in_vagrant
|
||||||
|
|
||||||
|
@ -71,7 +75,7 @@ class Config(object):
|
||||||
|
|
||||||
CACHE_MEMCACHED_SERVERS = ['127.0.0.1:11211']
|
CACHE_MEMCACHED_SERVERS = ['127.0.0.1:11211']
|
||||||
|
|
||||||
# Valid options: simple, elasticsearch, woosh
|
# Valid options: simple, elasticsearch, whoosh
|
||||||
SEARCH_TYPE = 'simple'
|
SEARCH_TYPE = 'simple'
|
||||||
|
|
||||||
ELASTICSEARCH_URL = 'http://127.0.0.1:9200'
|
ELASTICSEARCH_URL = 'http://127.0.0.1:9200'
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
from flask_sqlalchemy import DeclarativeMeta
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
from flask_sqlalchemy import DeclarativeMeta
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def hook_func(name, fn):
|
def hook_func(name, fn):
|
||||||
@wraps(fn)
|
@wraps(fn)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from sqlalchemy import not_, and_
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from sqlalchemy import not_, and_
|
||||||
|
|
||||||
from realms import db
|
from realms import db
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from flask_testing import TestCase
|
from flask_testing import TestCase
|
||||||
from realms.lib.util import random_string
|
|
||||||
from realms import create_app
|
from realms import create_app
|
||||||
|
from realms.lib.util import random_string
|
||||||
|
|
||||||
|
|
||||||
class BaseTest(TestCase):
|
class BaseTest(TestCase):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import click
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -6,6 +7,8 @@ import json
|
||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import click
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
from __future__ import absolute_import
|
|
@ -1,7 +1,10 @@
|
||||||
from realms import login_manager
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import request, flash, redirect
|
from flask import request, flash, redirect
|
||||||
from flask_login import login_url
|
from flask_login import login_url
|
||||||
|
|
||||||
|
from realms import login_manager
|
||||||
|
|
||||||
modules = set()
|
modules = set()
|
||||||
|
|
||||||
@login_manager.unauthorized_handler
|
@login_manager.unauthorized_handler
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
from ..models import Auth
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from realms.modules.auth.models import Auth
|
||||||
|
|
||||||
Auth.register('ldap')
|
Auth.register('ldap')
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask_wtf import Form
|
from flask_wtf import Form
|
||||||
from wtforms import StringField, PasswordField, validators
|
from wtforms import StringField, PasswordField, validators
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
from flask_login import login_user
|
from flask_login import login_user
|
||||||
from realms import ldap
|
|
||||||
from flask_ldap_login import LDAPLoginForm
|
from flask_ldap_login import LDAPLoginForm
|
||||||
from ..models import BaseUser
|
|
||||||
|
from realms import ldap
|
||||||
|
from realms.modules.auth.models import BaseUser
|
||||||
|
|
||||||
|
|
||||||
users = {}
|
users = {}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import current_app, request, redirect, Blueprint, flash, url_for, session
|
from flask import current_app, request, redirect, Blueprint, flash, url_for, session
|
||||||
from ..ldap.models import User
|
|
||||||
from flask_ldap_login import LDAPLoginForm
|
from flask_ldap_login import LDAPLoginForm
|
||||||
|
|
||||||
|
from .models import User
|
||||||
|
|
||||||
|
|
||||||
blueprint = Blueprint('auth.ldap', __name__)
|
blueprint = Blueprint('auth.ldap', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
from ..models import Auth
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from realms.modules.auth.models import Auth
|
||||||
|
|
||||||
Auth.register('local')
|
Auth.register('local')
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from realms.lib.util import random_string
|
|
||||||
from realms.modules.auth.local.models import User
|
|
||||||
from realms.lib.util import green, red, yellow
|
|
||||||
from realms import cli_group
|
from realms import cli_group
|
||||||
|
from realms.lib.util import random_string
|
||||||
|
from realms.lib.util import green, red, yellow
|
||||||
|
from .models import User
|
||||||
|
|
||||||
|
|
||||||
@cli_group(short_help="Auth Module")
|
@cli_group(short_help="Auth Module")
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask_wtf import Form
|
from flask_wtf import Form
|
||||||
from wtforms import StringField, PasswordField, validators
|
from wtforms import StringField, PasswordField, validators
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_wtf import RecaptchaField
|
from flask_wtf import RecaptchaField
|
||||||
|
|
||||||
from .forms import RegistrationForm
|
from .forms import RegistrationForm
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from hashlib import sha256
|
||||||
|
|
||||||
from flask import current_app, render_template
|
from flask import current_app, render_template
|
||||||
from flask_login import logout_user, login_user
|
from flask_login import logout_user, login_user
|
||||||
|
from itsdangerous import URLSafeSerializer, BadSignature
|
||||||
|
|
||||||
from realms import login_manager, db
|
from realms import login_manager, db
|
||||||
from realms.lib.model import Model
|
from realms.lib.model import Model
|
||||||
from ..models import BaseUser
|
from realms.modules.auth.models import BaseUser
|
||||||
from .forms import LoginForm
|
from .forms import LoginForm
|
||||||
from itsdangerous import URLSafeSerializer, BadSignature
|
|
||||||
from hashlib import sha256
|
|
||||||
|
|
||||||
|
|
||||||
@login_manager.token_loader
|
@login_manager.token_loader
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import current_app, render_template, request, redirect, Blueprint, flash, url_for, session
|
from flask import current_app, render_template, request, redirect, Blueprint, flash, url_for, session
|
||||||
from realms.modules.auth.local.models import User
|
|
||||||
from realms.modules.auth.local.forms import LoginForm, RegistrationForm
|
from .models import User
|
||||||
|
from .forms import LoginForm, RegistrationForm
|
||||||
|
|
||||||
|
|
||||||
blueprint = Blueprint('auth.local', __name__)
|
blueprint = Blueprint('auth.local', __name__)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import importlib
|
||||||
|
from hashlib import sha256
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_login import UserMixin, logout_user, AnonymousUserMixin
|
from flask_login import UserMixin, logout_user, AnonymousUserMixin
|
||||||
|
from itsdangerous import URLSafeSerializer, BadSignature
|
||||||
|
import bcrypt
|
||||||
|
|
||||||
from realms import login_manager
|
from realms import login_manager
|
||||||
from realms.lib.util import gravatar_url
|
from realms.lib.util import gravatar_url
|
||||||
from itsdangerous import URLSafeSerializer, BadSignature
|
|
||||||
from hashlib import sha256
|
|
||||||
from . import modules
|
from . import modules
|
||||||
import bcrypt
|
|
||||||
import importlib
|
|
||||||
|
|
||||||
|
|
||||||
@login_manager.user_loader
|
@login_manager.user_loader
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
from ..models import Auth
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from realms.modules.auth.models import Auth
|
||||||
|
|
||||||
Auth.register('oauth')
|
Auth.register('oauth')
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import session
|
from flask import session
|
||||||
from flask_login import login_user
|
from flask_login import login_user
|
||||||
from flask_oauthlib.client import OAuth
|
from flask_oauthlib.client import OAuth
|
||||||
|
|
||||||
from realms import config
|
from realms import config
|
||||||
from ..models import BaseUser
|
from realms.modules.auth.models import BaseUser
|
||||||
|
|
||||||
config = config.conf
|
config = config.conf
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import Blueprint, url_for, request, flash, redirect, session, current_app
|
from flask import Blueprint, url_for, request, flash, redirect, session, current_app
|
||||||
from .models import User
|
from .models import User
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
from __future__ import absolute_import
|
|
@ -1,6 +1,10 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import current_app, render_template, request, redirect, Blueprint, flash, url_for, session
|
from flask import current_app, render_template, request, redirect, Blueprint, flash, url_for, session
|
||||||
from flask_login import logout_user
|
from flask_login import logout_user
|
||||||
from realms.modules.auth.models import Auth
|
|
||||||
|
from .models import Auth
|
||||||
|
|
||||||
|
|
||||||
blueprint = Blueprint('auth', __name__, template_folder='templates')
|
blueprint = Blueprint('auth', __name__, template_folder='templates')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
from __future__ import absolute_import
|
|
@ -1,5 +1,8 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
from realms import search, cli_group
|
from realms import search, cli_group
|
||||||
from realms.modules.wiki.models import Wiki
|
from realms.modules.wiki.models import Wiki
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from realms.modules.wiki.models import WikiPage
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from realms import search
|
from realms import search
|
||||||
|
from realms.modules.wiki.models import WikiPage
|
||||||
|
|
||||||
|
|
||||||
@WikiPage.after('write')
|
@WikiPage.after('write')
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from flask import g, current_app
|
from flask import g, current_app
|
||||||
|
|
||||||
from realms.lib.util import filename_to_cname
|
from realms.lib.util import filename_to_cname
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import render_template, request, Blueprint, current_app
|
from flask import render_template, request, Blueprint, current_app
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
|
||||||
from realms import search as search_engine
|
from realms import search as search_engine
|
||||||
|
|
||||||
|
|
||||||
blueprint = Blueprint('search', __name__, template_folder='templates')
|
blueprint = Blueprint('search', __name__, template_folder='templates')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from realms.modules.wiki.models import Wiki
|
|
||||||
|
from .models import Wiki
|
||||||
|
|
||||||
|
|
||||||
def init(app):
|
def init(app):
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from realms import assets
|
from realms import assets
|
||||||
|
|
||||||
assets.register('editor.js',
|
assets.register('editor.js',
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from flask import g, current_app
|
from flask import g, current_app
|
||||||
|
|
||||||
from .models import Wiki
|
from .models import Wiki
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import posixpath
|
import posixpath
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import ghdiff
|
import ghdiff
|
||||||
import yaml
|
import yaml
|
||||||
from dulwich.object_store import tree_lookup_path
|
from dulwich.object_store import tree_lookup_path
|
||||||
from dulwich.repo import Repo, NotGitRepository
|
from dulwich.repo import Repo, NotGitRepository
|
||||||
from realms.lib.util import cname_to_filename, filename_to_cname
|
|
||||||
from realms import cache
|
from realms import cache
|
||||||
from realms.lib.hook import HookMixin
|
from realms.lib.hook import HookMixin
|
||||||
|
from realms.lib.util import cname_to_filename, filename_to_cname
|
||||||
|
|
||||||
|
|
||||||
class PageNotFound(Exception):
|
class PageNotFound(Exception):
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from nose.tools import *
|
from nose.tools import *
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
|
|
||||||
from realms.lib.util import cname_to_filename, filename_to_cname
|
from realms.lib.util import cname_to_filename, filename_to_cname
|
||||||
from realms.lib.test import BaseTest
|
from realms.lib.test import BaseTest
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from flask import abort, g, render_template, request, redirect, Blueprint, flash, url_for, current_app
|
from flask import abort, g, render_template, request, redirect, Blueprint, flash, url_for, current_app
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
|
||||||
from realms.lib.util import to_canonical, remove_ext, gravatar_url
|
from realms.lib.util import to_canonical, remove_ext, gravatar_url
|
||||||
from .models import PageNotFound
|
from .models import PageNotFound
|
||||||
|
|
||||||
|
|
||||||
blueprint = Blueprint('wiki', __name__, template_folder='templates',
|
blueprint = Blueprint('wiki', __name__, template_folder='templates',
|
||||||
static_folder='static', static_url_path='/static/wiki')
|
static_folder='static', static_url_path='/static/wiki')
|
||||||
|
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
__version__ = '0.8.1'
|
__version__ = '0.8.1'
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -1,5 +1,5 @@
|
||||||
from setuptools import setup, find_packages
|
|
||||||
import os
|
import os
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
if os.environ.get('USER', '') == 'vagrant':
|
if os.environ.get('USER', '') == 'vagrant':
|
||||||
del os.link
|
del os.link
|
||||||
|
@ -43,7 +43,8 @@ setup(name='realms-wiki',
|
||||||
'itsdangerous==0.24',
|
'itsdangerous==0.24',
|
||||||
'markdown2==2.3.1',
|
'markdown2==2.3.1',
|
||||||
'python-ldap==2.4.22',
|
'python-ldap==2.4.22',
|
||||||
'simplejson==3.6.3'
|
'simplejson==3.6.3',
|
||||||
|
'six==1.10.0'
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
|
|
Loading…
Reference in a new issue