blob: 8ab44d432c5a2ccf8213bc5b50c1c4e06aaf1b32 [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
8def count(lst):
9 c = 0
10 for l in lst[0]:
11 ll = l.lstrip()
12 if (ll and not ll.startswith('#') and ll.rstrip()!='pass' and 'ModelLink' not in ll and 'CHOICES' not in ll):
13 c+=1
14 return c
15
16def is_model_class(model):
17 """ Return True if 'model' is something that we're interested in """
18 if not inspect.isclass(model):
19 return False
20 if model.__name__ in ["PlModelMixIn"]:
21 return False
22 bases = inspect.getmro(model)
23 bases = [x.__name__ for x in bases]
Sapan Bhatia4e80a262017-05-19 23:10:51 +020024 if ("XOSBase" in bases) or ("PlModelMixIn" in bases):
Sapan Bhatia3d61cf82017-05-14 23:59:23 +020025 return True
26
27 return False
28
29for a in dir(core.models):
30 x = getattr(core.models,a)
31 if (is_model_class(x)):
32 lines = inspect.getsourcelines(x)
33 print x.__name__,":",count(lines)
34