Sapan Bhatia | 3d61cf8 | 2017-05-14 23:59:23 +0200 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import core.models |
| 4 | import inspect |
Sapan Bhatia | 4e80a26 | 2017-05-19 23:10:51 +0200 | [diff] [blame] | 5 | from core.models import XOSBase, PlModelMixIn |
Sapan Bhatia | 3d61cf8 | 2017-05-14 23:59:23 +0200 | [diff] [blame] | 6 | import pdb |
| 7 | |
| 8 | def 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 | |
| 16 | def 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 Bhatia | 4e80a26 | 2017-05-19 23:10:51 +0200 | [diff] [blame] | 24 | if ("XOSBase" in bases) or ("PlModelMixIn" in bases): |
Sapan Bhatia | 3d61cf8 | 2017-05-14 23:59:23 +0200 | [diff] [blame] | 25 | return True |
| 26 | |
| 27 | return False |
| 28 | |
| 29 | for 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 | |