From d8252f66b7d99caa7f31d9522f8514e8f6fb704b Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 31 Jan 2015 21:09:39 +0300 Subject: [PATCH] Move main() into powerline.bindings.pdb --- powerline/bindings/pdb/__init__.py | 19 +++++++++++++++++++ powerline/bindings/pdb/__main__.py | 22 +--------------------- 2 files changed, 20 insertions(+), 21 deletions(-) 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__':