Created
October 13, 2016 12:55
-
-
Save morefreeze/7b879a9209ea0f01a1d2ec5a9a6bb559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from __future__ import print_function | |
import csv | |
import sys | |
import datetime | |
from tqdm import tqdm | |
import importlib | |
import re | |
from decimal import Decimal | |
from ec.models.shop import ShopInfo | |
cls_list = [] | |
with open(sys.argv[1], 'r') as f: | |
for row in f: | |
path, cls_name, _ = row.split(':', 2) | |
mod_path = path[:-3].replace('/', '.') | |
cls_name = re.search('class (\w+)\(', cls_name).group(1) | |
mod = importlib.import_module(mod_path) | |
klass = getattr(mod, cls_name) | |
if not hasattr(klass, 'Meta'): | |
# print('Meta DO NOT exists in class %s' % (cls_name), file=sys.stderr) | |
continue | |
meta = getattr(klass, 'Meta') | |
for (fname, ftype, _, _, _, _) in ShopInfo.raw_sql('desc %s' % (meta.table)): | |
if re.match('float|double|decimal', ftype): | |
if not hasattr(meta.default, fname): | |
print('field %s DO NOT exists in %s.Meta.default' % (fname, cls_name), file=sys.stderr) | |
continue | |
field = getattr(meta.default, fname) | |
if not (isinstance(field, float) or isinstance(field, Decimal)): | |
print('%s:%s.%s type: %s, type_in_class: %s' % (path, meta.table, fname, ftype, type(field))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment