pep8 and other code-style changes
[wolnelektury.git] / src / wolnelektury / management / profile.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 import cProfile
6 import functools
7 import os
8
9 _object = None
10
11
12 def profile(meth):
13     def _wrapper(self, *args, **kwargs):
14         setattr(self, "__%s" % meth.__name__, meth)
15         cProfile.runctx(
16             'object.__%s(object, *args, **kwargs)' % (meth.__name__, ), globals(), locals(),
17             'profile.%d' % os.getpid())
18
19     functools.update_wrapper(_wrapper, meth)
20     return _wrapper