From 5cebc45e0da105c13bfc9b238519cb2c8f9a8dac Mon Sep 17 00:00:00 2001 From: Derek Anderson Date: Mon, 17 Oct 2016 10:52:48 -0500 Subject: [PATCH] fixed import error on dep check --- peeweedbevolve.py | 36 ++++++++++++++++++++++-------------- setup.py | 3 ++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/peeweedbevolve.py b/peeweedbevolve.py index 38a1ee8..67fb7e0 100644 --- a/peeweedbevolve.py +++ b/peeweedbevolve.py @@ -2,8 +2,11 @@ import collections, re, sys, time -import colorama -colorama.init() +try: + import colorama + colorama.init() +except ImportError: + print('colorama not installed') import peewee as pw import playhouse.migrate @@ -14,7 +17,7 @@ # peewee doesn't do defaults in the database - doh! DIFF_DEFAULTS = False -__version__ = '0.4.4' +__version__ = '0.4.5' try: @@ -491,19 +494,24 @@ def _execute(db, to_run, interactive=True, commit=True): print() raise e -COLORED_WORDS = [ - (colorama.Fore.GREEN, ['CREATE', 'ADD']), - (colorama.Fore.YELLOW, ['ALTER', 'SET', 'RENAME']), - (colorama.Fore.RED, ['DROP']), - (colorama.Style.BRIGHT + colorama.Fore.BLUE, ['INTEGER','VARCHAR','TIMESTAMP','TEXT','SERIAL']), - (colorama.Style.BRIGHT, ['BEGIN','COMMIT']), - (colorama.Fore.CYAN, ['FOREIGN KEY', 'REFERENCES', 'UNIQUE']), - (colorama.Style.BRIGHT + colorama.Fore.CYAN, ['PRIMARY KEY']), - (colorama.Style.BRIGHT + colorama.Fore.MAGENTA, ['NOT NULL','NULL']), - (colorama.Style.DIM, [' ON ', '(', ')', 'INDEX', 'TABLE', 'COLUMN', 'CONSTRAINT' ,' TO ',';']), -] +COLORED_WORDS = None + +def init_COLORED_WORDS(): + global COLORED_WORDS + COLORED_WORDS = [ + (colorama.Fore.GREEN, ['CREATE', 'ADD']), + (colorama.Fore.YELLOW, ['ALTER', 'SET', 'RENAME']), + (colorama.Fore.RED, ['DROP']), + (colorama.Style.BRIGHT + colorama.Fore.BLUE, ['INTEGER','VARCHAR','TIMESTAMP','TEXT','SERIAL']), + (colorama.Style.BRIGHT, ['BEGIN','COMMIT']), + (colorama.Fore.CYAN, ['FOREIGN KEY', 'REFERENCES', 'UNIQUE']), + (colorama.Style.BRIGHT + colorama.Fore.CYAN, ['PRIMARY KEY']), + (colorama.Style.BRIGHT + colorama.Fore.MAGENTA, ['NOT NULL','NULL']), + (colorama.Style.DIM, [' ON ', '(', ')', 'INDEX', 'TABLE', 'COLUMN', 'CONSTRAINT' ,' TO ',';']), + ] def print_sql(sql): + if COLORED_WORDS is None: init_COLORED_WORDS() for color, patterns in COLORED_WORDS: for pattern in patterns: sql = sql.replace(pattern, color + pattern + colorama.Style.RESET_ALL) diff --git a/setup.py b/setup.py index 9cac375..0317197 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ import os -from distutils.core import setup + +from setuptools import setup def long_description(): os.system('pandoc --from=markdown --to=rst --output=README.rst README.md')