From 9608e991500f8daea3565e982e0788bcdbb81ade Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 18 Dec 2018 15:54:47 +0100 Subject: [PATCH] #23 Fix errors and flake8 --- django_migration_linter/constants.py | 4 +++- django_migration_linter/utils.py | 2 +- setup.py | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/django_migration_linter/constants.py b/django_migration_linter/constants.py index 3086825..a667d9a 100644 --- a/django_migration_linter/constants.py +++ b/django_migration_linter/constants.py @@ -18,4 +18,6 @@ from appdirs import user_cache_dir __VERSION__ = '0.0.7' -DEFAULT_CACHE_PATH = Path(user_cache_dir("django-migration-linter", version=__VERSION__)) +DEFAULT_CACHE_PATH = Path( + user_cache_dir("django-migration-linter", version=__VERSION__) +) diff --git a/django_migration_linter/utils.py b/django_migration_linter/utils.py index 4575a4f..0f83ad5 100644 --- a/django_migration_linter/utils.py +++ b/django_migration_linter/utils.py @@ -59,4 +59,4 @@ def clean_bytes_to_str(byte_input): def get_default_cache_file(project_name): - os.join(DEFAULT_CACHE_PATH, '{0}.pickle'.format(project_name)) + return os.path.join(DEFAULT_CACHE_PATH, '{0}.pickle'.format(project_name)) diff --git a/setup.py b/setup.py index c1f728c..7337984 100644 --- a/setup.py +++ b/setup.py @@ -11,15 +11,23 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +import ast +import re from os import path from setuptools import setup, find_packages PROJECT_DIR = path.abspath(path.dirname(__file__)) -# Read __VERSION__ -exec(open('./django_migration_linter/constants.py').read()) + +def get_version(): + constants = path.join(PROJECT_DIR, 'django_migration_linter', 'constants.py') + _version_re = re.compile(r"__VERSION__\s+=\s+(?P.*)") + with open(constants, "r") as f: + match = _version_re.search(f.read()) + version = match.group("version") if match is not None else '"unknown"' + return str(ast.literal_eval(version)) + with open(path.join(PROJECT_DIR, 'README.rst')) as f: @@ -39,7 +47,7 @@ test_requirements = [ # noinspection PyUnresolvedReferences setup( name='django-migration-linter', - version=__VERSION__, + version=get_version(), description='Detect backward incompatible migrations for your django project', long_description=long_description,