diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2017-06-28 21:36:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-28 21:36:02 +0200 |
| commit | 0e374cd5e0ef5a9be67084365f91de2ab84f636c (patch) | |
| tree | d6b512090f6cadb9369596af666ef1bf198b63b7 /budget | |
| parent | 603ac10d6eb485c9a95f253a14d4967f4aafbfa3 (diff) | |
| download | ihatemoney-mirror-0e374cd5e0ef5a9be67084365f91de2ab84f636c.zip ihatemoney-mirror-0e374cd5e0ef5a9be67084365f91de2ab84f636c.tar.gz ihatemoney-mirror-0e374cd5e0ef5a9be67084365f91de2ab84f636c.tar.bz2 | |
Make all imports relative (#229)
* Make all imports relative
* Change the way the application runs in the Makefile
* Import the default settings relatively
* Fix manage.py imports
Diffstat (limited to 'budget')
| -rw-r--r-- | budget/api.py | 6 | ||||
| -rw-r--r-- | budget/forms.py | 5 | ||||
| -rwxr-xr-x | budget/manage.py | 14 | ||||
| -rw-r--r-- | budget/run.py | 10 | ||||
| -rw-r--r-- | budget/tests/tests.py | 6 | ||||
| -rw-r--r-- | budget/web.py | 17 |
6 files changed, 33 insertions, 25 deletions
diff --git a/budget/api.py b/budget/api.py index 4b991bd..7ce6a34 100644 --- a/budget/api.py +++ b/budget/api.py @@ -2,9 +2,9 @@ from flask import Blueprint, request from flask_rest import RESTResource, need_auth -from models import db, Project, Person, Bill -from forms import (ProjectForm, EditProjectForm, MemberForm, - get_billform_for) +from .models import db, Project, Person, Bill +from .forms import (ProjectForm, EditProjectForm, MemberForm, + get_billform_for) api = Blueprint("api", __name__, url_prefix="/api") diff --git a/budget/forms.py b/budget/forms.py index 06df743..bd7fc5b 100644 --- a/budget/forms.py +++ b/budget/forms.py @@ -7,10 +7,11 @@ from flask_babel import lazy_gettext as _ from flask import request from wtforms.widgets import html_params -from models import Project, Person from datetime import datetime from jinja2 import Markup -from utils import slugify + +from .models import Project, Person +from .utils import slugify def get_billform_for(project, set_default=True, **kwargs): """Return an instance of BillForm configured for a particular project. diff --git a/budget/manage.py b/budget/manage.py index f717fed..0a66284 100755 --- a/budget/manage.py +++ b/budget/manage.py @@ -1,12 +1,12 @@ #!/usr/bin/env python +from getpass import getpass from flask_script import Manager, Command from flask_migrate import Migrate, MigrateCommand from werkzeug.security import generate_password_hash -from run import app -from models import db -from getpass import getpass +from .run import app +from .models import db class GeneratePasswordHash(Command): @@ -20,8 +20,12 @@ migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) -manager.add_command('generate_password_hash', GeneratePasswordHash) +manager.add_command('generate_password_hash', GeneratePasswordHash) -if __name__ == '__main__': +def main(): manager.run() + + +if __name__ == '__main__': + main() diff --git a/budget/run.py b/budget/run.py index 7fe4e24..5e65c90 100644 --- a/budget/run.py +++ b/budget/run.py @@ -7,12 +7,12 @@ from flask_babel import Babel from flask_migrate import Migrate, upgrade, stamp from raven.contrib.flask import Sentry -from web import main, db, mail -from api import api -from utils import PrefixedWSGI -from utils import minimal_round +from .web import main, db, mail +from .api import api +from .utils import PrefixedWSGI +from .utils import minimal_round -import default_settings +from . import default_settings app = Flask(__name__, instance_path='/etc/ihatemoney', instance_relative_config=True) diff --git a/budget/tests/tests.py b/budget/tests/tests.py index 16aaae9..386920f 100644 --- a/budget/tests/tests.py +++ b/budget/tests/tests.py @@ -17,9 +17,9 @@ from flask import session if 'IHATEMONEY_SETTINGS_FILE_PATH' in os.environ: del os.environ['IHATEMONEY_SETTINGS_FILE_PATH'] -import run -import models -import utils +from .. import run +from .. import models +from .. import utils __HERE__ = os.path.dirname(os.path.abspath(__file__)) diff --git a/budget/web.py b/budget/web.py index f4961cb..ba77124 100644 --- a/budget/web.py +++ b/budget/web.py @@ -9,8 +9,10 @@ some shortcuts to make your life better when coding (see `pull_project` and `add_project_id` for a quick overview) """ -from flask import Blueprint, current_app, flash, g, redirect, \ - render_template, request, session, url_for, send_file +from flask import ( + Blueprint, current_app, flash, g, redirect, render_template, request, + session, url_for, send_file +) from flask_mail import Mail, Message from flask_babel import get_locale, gettext as _ from werkzeug.security import generate_password_hash, \ @@ -20,12 +22,13 @@ import werkzeug from sqlalchemy import orm from functools import wraps -# local modules -from models import db, Project, Person, Bill -from forms import AdminAuthenticationForm, AuthenticationForm, EditProjectForm, \ - InviteForm, MemberForm, PasswordReminder, ProjectForm, get_billform_for, \ +from .models import db, Project, Person, Bill +from .forms import ( + AdminAuthenticationForm, AuthenticationForm, EditProjectForm, + InviteForm, MemberForm, PasswordReminder, ProjectForm, get_billform_for, ExportForm -from utils import Redirect303, list_of_dicts2json, list_of_dicts2csv +) +from .utils import Redirect303, list_of_dicts2json, list_of_dicts2csv main = Blueprint("main", __name__) mail = Mail() |
