Make imports relative
This commit is contained in:
1 parent
b1716b9d1d
commit
92a686f13b
4 files changed
+12
-14
No files matched your search
@@ -16,7 +16,7 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
from django_migration_linter.utils import split_path
|
from .utils import split_path
|
||||||
|
|
||||||
|
|
||||||
class Cache(dict):
|
class Cache(dict):
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ import re
|
|||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django_migration_linter.cache import Cache
|
from .cache import Cache
|
||||||
from django_migration_linter.constants import DEFAULT_CACHE_PATH, MIGRATION_FOLDER_NAME
|
from .constants import DEFAULT_CACHE_PATH, MIGRATION_FOLDER_NAME
|
||||||
from . import utils
|
|
||||||
from .migration import Migration
|
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
|
from .sql_analyser import analyse_sql_statements
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -31,13 +31,13 @@ logger = logging.getLogger(__name__)
|
|||||||
class MigrationLinter(object):
|
class MigrationLinter(object):
|
||||||
def __init__(self, project_path, **kwargs):
|
def __init__(self, project_path, **kwargs):
|
||||||
# Verify correctness
|
# Verify correctness
|
||||||
if not utils.is_directory(project_path):
|
if not is_directory(project_path):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"The given path {0} does not seem to be a directory.".format(
|
"The given path {0} does not seem to be a directory.".format(
|
||||||
project_path
|
project_path
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if not utils.is_django_project(project_path):
|
if not is_django_project(project_path):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
("The given path {0} does not " "seem to be a django project.").format(
|
("The given path {0} does not " "seem to be a django project.").format(
|
||||||
project_path
|
project_path
|
||||||
@@ -136,7 +136,7 @@ class MigrationLinter(object):
|
|||||||
def lint_all_migrations(self, git_commit_id=None):
|
def lint_all_migrations(self, git_commit_id=None):
|
||||||
# Collect migrations
|
# Collect migrations
|
||||||
if git_commit_id:
|
if git_commit_id:
|
||||||
if not utils.is_git_project(self.django_path):
|
if not is_git_project(self.django_path):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
(
|
(
|
||||||
"The given project {0} does not seem " "to be versioned by git."
|
"The given project {0} does not seem " "to be versioned by git."
|
||||||
@@ -190,9 +190,7 @@ class MigrationLinter(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
sql_statements = []
|
sql_statements = []
|
||||||
for line in map(
|
for line in map(clean_bytes_to_str, sqlmigrate_process.stdout.readlines()):
|
||||||
utils.clean_bytes_to_str, sqlmigrate_process.stdout.readlines()
|
|
||||||
):
|
|
||||||
sql_statements.append(line)
|
sql_statements.append(line)
|
||||||
sqlmigrate_process.wait()
|
sqlmigrate_process.wait()
|
||||||
if sqlmigrate_process.returncode != 0:
|
if sqlmigrate_process.returncode != 0:
|
||||||
@@ -211,7 +209,7 @@ class MigrationLinter(object):
|
|||||||
).format(self.django_path, git_commit_id)
|
).format(self.django_path, git_commit_id)
|
||||||
logger.info("Executing {0}".format(git_diff_command))
|
logger.info("Executing {0}".format(git_diff_command))
|
||||||
diff_process = Popen(git_diff_command, shell=True, stdout=PIPE, stderr=PIPE)
|
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
|
# Only gather lines that include added migrations
|
||||||
if (
|
if (
|
||||||
re.search(r"\/{0}\/.*\.py".format(MIGRATION_FOLDER_NAME), line)
|
re.search(r"\/{0}\/.*\.py".format(MIGRATION_FOLDER_NAME), line)
|
||||||
@@ -222,7 +220,7 @@ class MigrationLinter(object):
|
|||||||
|
|
||||||
if diff_process.returncode != 0:
|
if diff_process.returncode != 0:
|
||||||
output = []
|
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)
|
output.append(line)
|
||||||
logger.info("Error while git diff command:\n{}".format("".join(output)))
|
logger.info("Error while git diff command:\n{}".format("".join(output)))
|
||||||
raise Exception("Error while executing git diff command")
|
raise Exception("Error while executing git diff command")
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django_migration_linter.operations import IGNORE_MIGRATION_SQL
|
from .operations import IGNORE_MIGRATION_SQL
|
||||||
|
|
||||||
IGNORED_MIGRATION = "IGNORED_MIGRATION"
|
IGNORED_MIGRATION = "IGNORED_MIGRATION"
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from __future__ import print_function
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django_migration_linter.constants import MIGRATION_FOLDER_NAME
|
from .constants import MIGRATION_FOLDER_NAME
|
||||||
|
|
||||||
|
|
||||||
def is_django_project(path):
|
def is_django_project(path):
|
||||||
|
|||||||
Reference in new issue
Block a user