diff --git a/powerline/bindings/pdb/__init__.py b/powerline/bindings/pdb/__init__.py index 48b8a606..4033e611 100644 --- a/powerline/bindings/pdb/__init__.py +++ b/powerline/bindings/pdb/__init__.py @@ -2,6 +2,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_function) import sys +import pdb from powerline.pdb import PDBPowerline from powerline.lib.encoding import get_preferred_output_encoding @@ -162,3 +163,21 @@ def use_powerline_prompt(cls): cls.prompt = prompt return cls + + +def main(): + '''Run module as a script + + Uses :py:func:`pdb.main` function directly, but prior to that it mocks + :py:class:`pdb.Pdb` class with powerline-specific class instance. + ''' + orig_pdb = pdb.Pdb + + @use_powerline_prompt + class Pdb(pdb.Pdb, object): + def __init__(self): + orig_pdb.__init__(self) + + pdb.Pdb = Pdb + + return pdb.main() diff --git a/powerline/bindings/pdb/__main__.py b/powerline/bindings/pdb/__main__.py index 78527500..768b2f29 100755 --- a/powerline/bindings/pdb/__main__.py +++ b/powerline/bindings/pdb/__main__.py @@ -2,27 +2,7 @@ # vim:fileencoding=utf-8:noet from __future__ import (unicode_literals, division, absolute_import, print_function) -import pdb - -from powerline.bindings.pdb import use_powerline_prompt - - -def main(): - '''Run module as a script - - Uses :py:func:`pdb.main` function directly, but prior to that it mocks - :py:class:`pdb.Pdb` class with powerline-specific class instance. - ''' - orig_pdb = pdb.Pdb - - @use_powerline_prompt - class Pdb(pdb.Pdb, object): - def __init__(self): - orig_pdb.__init__(self) - - pdb.Pdb = Pdb - - return pdb.main() +from powerline.bindings.pdb import main if __name__ == '__main__':