Skip to content

Commit

Permalink
fixed import error on dep check
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Anderson committed Oct 17, 2016
1 parent 9bb9525 commit 5cebc45
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
36 changes: 22 additions & 14 deletions peeweedbevolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down

0 comments on commit 5cebc45

Please sign in to comment.