blob: bfbbd7ccd8d93a549de2feef333a5aadb17114d9 [file] [log] [blame]
Sapan Bhatia3d61cf82017-05-14 23:59:23 +02001#!/usr/bin/python
2
3import core.models
4import inspect
Sapan Bhatia4e80a262017-05-19 23:10:51 +02005from core.models import XOSBase, PlModelMixIn
Sapan Bhatia3d61cf82017-05-14 23:59:23 +02006import pdb
7
Zack Williams045b63d2019-01-22 16:30:57 -07008
Sapan Bhatia3d61cf82017-05-14 23:59:23 +02009def count(lst):
10 c = 0
11 for l in lst[0]:
Zack Williams045b63d2019-01-22 16:30:57 -070012 ll = l.lstrip()
13 if (ll and not ll.startswith('#') and ll.rstrip() != 'pass' and 'ModelLink' not in ll and 'CHOICES' not in ll):
14 c += 1
Sapan Bhatia3d61cf82017-05-14 23:59:23 +020015 return c
16
Zack Williams045b63d2019-01-22 16:30:57 -070017
Sapan Bhatia3d61cf82017-05-14 23:59:23 +020018def is_model_class(model):
19 """ Return True if 'model' is something that we're interested in """
20 if not inspect.isclass(model):
21 return False
22 if model.__name__ in ["PlModelMixIn"]:
23 return False
24 bases = inspect.getmro(model)
25 bases = [x.__name__ for x in bases]
Sapan Bhatia4e80a262017-05-19 23:10:51 +020026 if ("XOSBase" in bases) or ("PlModelMixIn" in bases):
Sapan Bhatia3d61cf82017-05-14 23:59:23 +020027 return True
28
29 return False
30
Zack Williams045b63d2019-01-22 16:30:57 -070031
Sapan Bhatia3d61cf82017-05-14 23:59:23 +020032for a in dir(core.models):
Zack Williams045b63d2019-01-22 16:30:57 -070033 x = getattr(core.models, a)
Sapan Bhatia3d61cf82017-05-14 23:59:23 +020034 if (is_model_class(x)):
35 lines = inspect.getsourcelines(x)
Zack Williams045b63d2019-01-22 16:30:57 -070036 print x.__name__, ":", count(lines)