Skip to content

Commit

Permalink
Make imports relative
Browse files Browse the repository at this point in the history
  • Loading branch information
flixx authored and David-Wobrock committed Jan 5, 2019
1 parent b1716b9 commit 92a686f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion django_migration_linter/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import os
import pickle

from django_migration_linter.utils import split_path
from .utils import split_path


class Cache(dict):
Expand Down
20 changes: 9 additions & 11 deletions django_migration_linter/migration_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from subprocess import Popen, PIPE
import sys

from django_migration_linter.cache import Cache
from django_migration_linter.constants import DEFAULT_CACHE_PATH, MIGRATION_FOLDER_NAME
from . import utils
from .cache import Cache
from .constants import DEFAULT_CACHE_PATH, MIGRATION_FOLDER_NAME
from .migration import Migration
from .utils import is_directory, is_django_project, is_git_project, clean_bytes_to_str
from .sql_analyser import analyse_sql_statements

logger = logging.getLogger(__name__)
Expand All @@ -31,13 +31,13 @@
class MigrationLinter(object):
def __init__(self, project_path, **kwargs):
# Verify correctness
if not utils.is_directory(project_path):
if not is_directory(project_path):
raise ValueError(
"The given path {0} does not seem to be a directory.".format(
project_path
)
)
if not utils.is_django_project(project_path):
if not is_django_project(project_path):
raise ValueError(
("The given path {0} does not " "seem to be a django project.").format(
project_path
Expand Down Expand Up @@ -136,7 +136,7 @@ def print_errors(errors):
def lint_all_migrations(self, git_commit_id=None):
# Collect migrations
if git_commit_id:
if not utils.is_git_project(self.django_path):
if not is_git_project(self.django_path):
raise ValueError(
(
"The given project {0} does not seem " "to be versioned by git."
Expand Down Expand Up @@ -190,9 +190,7 @@ def get_sql(self, app_name, migration_name):
)

sql_statements = []
for line in map(
utils.clean_bytes_to_str, sqlmigrate_process.stdout.readlines()
):
for line in map(clean_bytes_to_str, sqlmigrate_process.stdout.readlines()):
sql_statements.append(line)
sqlmigrate_process.wait()
if sqlmigrate_process.returncode != 0:
Expand All @@ -211,7 +209,7 @@ def _gather_migrations_git(self, git_commit_id):
).format(self.django_path, git_commit_id)
logger.info("Executing {0}".format(git_diff_command))
diff_process = Popen(git_diff_command, shell=True, stdout=PIPE, stderr=PIPE)
for line in map(utils.clean_bytes_to_str, diff_process.stdout.readlines()):
for line in map(clean_bytes_to_str, diff_process.stdout.readlines()):
# Only gather lines that include added migrations
if (
re.search(r"\/{0}\/.*\.py".format(MIGRATION_FOLDER_NAME), line)
Expand All @@ -222,7 +220,7 @@ def _gather_migrations_git(self, git_commit_id):

if diff_process.returncode != 0:
output = []
for line in map(utils.clean_bytes_to_str, diff_process.stderr.readlines()):
for line in map(clean_bytes_to_str, diff_process.stderr.readlines()):
output.append(line)
logger.info("Error while git diff command:\n{}".format("".join(output)))
raise Exception("Error while executing git diff command")
Expand Down
2 changes: 1 addition & 1 deletion django_migration_linter/sql_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import re
import logging

from django_migration_linter.operations import IGNORE_MIGRATION_SQL
from .operations import IGNORE_MIGRATION_SQL

IGNORED_MIGRATION = "IGNORED_MIGRATION"

Expand Down
2 changes: 1 addition & 1 deletion django_migration_linter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os
import sys

from django_migration_linter.constants import MIGRATION_FOLDER_NAME
from .constants import MIGRATION_FOLDER_NAME


def is_django_project(path):
Expand Down

0 comments on commit 92a686f

Please sign in to comment.