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