Finish up cache and fix tests.

Still TODO: Merge with ignore functionality.
This commit is contained in:
Felix committed 2018-12-20 14:45:35 +01:00
1 parent 9608e99150
commit b68c0183bb
11 files changed
+263 -106

No files matched your search

+20 -3
View File
@@ -13,10 +13,11 @@
# limitations under the License.
from __future__ import print_function
import os
import sys
from django_migration_linter.constants import DEFAULT_CACHE_PATH
from django_migration_linter.constants import MIGRATION_FOLDER_NAME
def is_django_project(path):
@@ -54,9 +55,25 @@ def split_path(path):
return (split_path(a) if (len(a) > 0 and a != '/') else []) + [b]
def split_migration_path(migration_path):
decomposed_path = split_path(migration_path)
for i, p in enumerate(decomposed_path):
if p == MIGRATION_FOLDER_NAME:
return (decomposed_path[i-1],
os.path.splitext(decomposed_path[i+1])[0])
def compose_migration_path(django_folder, app_name, migration):
return os.path.join(
django_folder,
app_name,
MIGRATION_FOLDER_NAME,
'{0}.py'.format(migration)
)
def clean_bytes_to_str(byte_input):
return byte_input.decode('utf-8').strip()
def get_default_cache_file(project_name):
return os.path.join(DEFAULT_CACHE_PATH, '{0}.pickle'.format(project_name))