From 74bb67b94e1224354757c9f0e1793e13bac44a0d Mon Sep 17 00:00:00 2001 From: byronyi Date: Fri, 22 Aug 2014 16:21:17 +0800 Subject: [PATCH 01/16] add gitignore --- .gitignore | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2a9cb21..00039fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,53 @@ -.tox -coverage +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ From 530317e7447df6ee1d00b7813719cc3e6b1a4f31 Mon Sep 17 00:00:00 2001 From: byronyi Date: Fri, 22 Aug 2014 18:53:46 +0800 Subject: [PATCH 02/16] test passed --- manual_test.py | 5 ++- setup.py | 1 + src/vimpdb/bbbconfig.py | 8 ++-- src/vimpdb/config.py | 46 ++++++++++----------- src/vimpdb/debugger.py | 10 +++-- src/vimpdb/tests/scripts/compatiblevim.py | 5 ++- src/vimpdb/tests/scripts/nopython.py | 5 ++- src/vimpdb/tests/scripts/noserver.py | 5 ++- src/vimpdb/tests/scripts/rightserverlist.py | 5 ++- src/vimpdb/tests/scripts/wrongserverlist.py | 5 ++- 10 files changed, 58 insertions(+), 37 deletions(-) diff --git a/manual_test.py b/manual_test.py index d9436aa..d3a2475 100644 --- a/manual_test.py +++ b/manual_test.py @@ -1,5 +1,8 @@ +from __future__ import print_function + + def output(arg): - print "MANUAL: arg=", arg + print("MANUAL: arg={}".format(arg)) def main(): diff --git a/setup.py b/setup.py index 9fdeb4b..59b8465 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ zip_safe=False, install_requires=[ 'vim_bridge', + 'six' ], entry_points=""" # -*- Entry points: -*- diff --git a/src/vimpdb/bbbconfig.py b/src/vimpdb/bbbconfig.py index 7160212..4b889ad 100644 --- a/src/vimpdb/bbbconfig.py +++ b/src/vimpdb/bbbconfig.py @@ -1,17 +1,17 @@ import os -import ConfigParser +from six.moves import configparser from vimpdb import errors def read_from_file_4_0(filename, klass): - parser = ConfigParser.RawConfigParser() + parser = configparser.RawConfigParser() parser.read(filename) if not parser.has_section('vimpdb'): raise errors.BadRCFile('[vimpdb] section is missing in "%s"' % - filename) + filename) error_msg = ("'%s' option is missing from section [vimpdb] in " - + "'" + filename + "'.") + + "'" + filename + "'.") if parser.has_option('vimpdb', 'script'): vim_client_script = parser.get('vimpdb', 'script') else: diff --git a/src/vimpdb/config.py b/src/vimpdb/config.py index cdcf67d..3cd8d2a 100755 --- a/src/vimpdb/config.py +++ b/src/vimpdb/config.py @@ -3,7 +3,7 @@ import os.path import logging import time -import ConfigParser +from six.moves import configparser import subprocess from vimpdb import bbbconfig @@ -85,7 +85,7 @@ def get_configuration(filename=RCNAME): mustWrite = False try: config = read_from_file(filename, Config) - except errors.BadRCFile, e: + except errors.BadRCFile as e: try: config_4_0 = bbbconfig.read_from_file_4_0(filename, Config) except errors.BadRCFile: @@ -107,7 +107,7 @@ def getRawConfiguration(filename=RCNAME): def read_from_file(filename, klass): - parser = ConfigParser.RawConfigParser() + parser = configparser.RawConfigParser() parser.read(filename) if not parser.has_section('vimpdb'): raise errors.BadRCFile('[vimpdb] section is missing in "%s"' % @@ -135,7 +135,7 @@ def read_option(parser, name, error_msg): def write_to_file(filename, config): - parser = ConfigParser.RawConfigParser() + parser = configparser.RawConfigParser() parser.add_section('vimpdb') parser.set('vimpdb', 'vim_client_script', config.scripts[CLIENT]) parser.set('vimpdb', 'vim_server_script', config.scripts[SERVER]) @@ -150,14 +150,14 @@ def getCommandOutputPosix(parts): try: p = subprocess.Popen(parts, stdout=subprocess.PIPE) return_code = p.wait() - except OSError, e: + except OSError as e: message = 'When trying to run "%s" : %s' % (" ".join(parts), e.args[1]) raise OSError(e.args[0], message) if return_code: raise errors.ReturnCodeError(return_code, " ".join(parts)) child_stdout = p.stdout output = child_stdout.read() - return output.strip() + return output.decode().strip() NO_SERVER_SUPPORT = ("'%s' launches a VIM instance without " @@ -191,15 +191,15 @@ def checkConfiguration(self): def _checkConfiguration(self): try: self.check_clientserver_support(CLIENT) - except ValueError, e: - print e.args[0] + except ValueError as e: + print(e.args[0]) self.query_script(CLIENT) return False try: self.check_python_support() #XXX catch WindowsError - except OSError, e: - print e.args[1] + except OSError as e: + print(e.args[1]) server_script = self.scripts[SERVER] if server_script == DEFAULT_SERVER_SCRIPT: print ("with the default VIM server script (%s)." @@ -209,20 +209,20 @@ def _checkConfiguration(self): "(%s)." % server_script) self.query_script(SERVER) return False - except ValueError, e: - print e.args[0] + except ValueError as e: + print(e.args[0]) self.query_script(SERVER) return False try: self.check_server_clientserver_support() - except ValueError, e: - print e.args[0] + except ValueError as e: + print(e.args[0]) self.query_script(SERVER) return False try: self.check_serverlist() - except ValueError, e: - print e.args[0] + except ValueError as e: + print(e.args[0]) self.query_servername() return False return True @@ -240,11 +240,11 @@ def get_serverlist(self): command = self.build_command(CLIENT, '--serverlist') try: return self.commandParser(command) - except errors.ReturnCodeError, e: + except errors.ReturnCodeError as e: return_code = e.args[0] command = e.args[1] raise ValueError(RETURN_CODE % (command, return_code)) - except OSError, e: + except OSError as e: raise ValueError(str(e)) def serverAvailable(self): @@ -260,11 +260,11 @@ def check_serverlist(self): if not self.serverAvailable(): try: self.launch_vim_server() - except errors.ReturnCodeError, e: + except errors.ReturnCodeError as e: return_code = e.args[0] command = e.args[1] raise ValueError(RETURN_CODE % (command, return_code)) - except OSError, e: + except OSError as e: raise ValueError(str(e)) timeout = 0.0 INCREMENT = 0.1 @@ -284,11 +284,11 @@ def get_vim_version(self, script_type): try: command = self.build_command(script_type, '--version') return self.commandParser(command) - except errors.ReturnCodeError, e: + except errors.ReturnCodeError as e: return_code = e.args[0] command = e.args[1] raise ValueError(RETURN_CODE % (command, return_code)) - except OSError, e: + except OSError as e: raise ValueError(str(e)) def check_clientserver_support(self, script_type): @@ -331,7 +331,7 @@ def query_servername(self): def getCommandOutputWindows(parts): try: - return getCommandOutputPosix(parts) + return getCommandOutputPosix(parts).decode('utf-8') except WindowsError: raise errors.ReturnCodeError(1, " ".join(parts)) diff --git a/src/vimpdb/debugger.py b/src/vimpdb/debugger.py index db372cf..5cc36b3 100755 --- a/src/vimpdb/debugger.py +++ b/src/vimpdb/debugger.py @@ -1,7 +1,9 @@ +from __future__ import print_function + import pdb from pdb import Pdb import sys -import StringIO +from six.moves import StringIO import pprint from vimpdb import proxy from vimpdb import config @@ -129,7 +131,7 @@ def showFileAtLine(self): self.to_vim.displayLocals(watches) def formatLocals(self): - stream = StringIO.StringIO() + stream = StringIO() locals = self.curframe.f_locals keys = locals.keys() keys.sort() @@ -145,7 +147,7 @@ def formatLocals(self): # stdout captures to send back to Vim def capture_sys_stdout(self): self.stdout = sys.stdout - sys.stdout = StringIO.StringIO() + sys.stdout = StringIO() self.capturing = True def stop_capture_sys_stdout(self): @@ -157,7 +159,7 @@ def stop_capture_sys_stdout(self): # stdout captures to send back to Vim def capture_self_stdout(self): self.initial_stdout = self.stdout - self.stdout = StringIO.StringIO() + self.stdout = StringIO() self.capturing = True def stop_capture_self_stdout(self): diff --git a/src/vimpdb/tests/scripts/compatiblevim.py b/src/vimpdb/tests/scripts/compatiblevim.py index 4fd38c8..056422e 100644 --- a/src/vimpdb/tests/scripts/compatiblevim.py +++ b/src/vimpdb/tests/scripts/compatiblevim.py @@ -1 +1,4 @@ -print "+clientserver +python" +from __future__ import print_function + + +print("+clientserver +python") diff --git a/src/vimpdb/tests/scripts/nopython.py b/src/vimpdb/tests/scripts/nopython.py index 195eaba..04cdfc2 100644 --- a/src/vimpdb/tests/scripts/nopython.py +++ b/src/vimpdb/tests/scripts/nopython.py @@ -1 +1,4 @@ -print "+clientserver -python" +from __future__ import print_function + + +print("+clientserver -python") diff --git a/src/vimpdb/tests/scripts/noserver.py b/src/vimpdb/tests/scripts/noserver.py index 5f40c37..b204d5c 100644 --- a/src/vimpdb/tests/scripts/noserver.py +++ b/src/vimpdb/tests/scripts/noserver.py @@ -1 +1,4 @@ -print "-clientserver +python" +from __future__ import print_function + + +print("-clientserver +python") diff --git a/src/vimpdb/tests/scripts/rightserverlist.py b/src/vimpdb/tests/scripts/rightserverlist.py index 1fb3be1..8d04081 100644 --- a/src/vimpdb/tests/scripts/rightserverlist.py +++ b/src/vimpdb/tests/scripts/rightserverlist.py @@ -1 +1,4 @@ -print "VIM" +from __future__ import print_function + + +print("VIM") diff --git a/src/vimpdb/tests/scripts/wrongserverlist.py b/src/vimpdb/tests/scripts/wrongserverlist.py index 1c7fc09..c9ee86e 100644 --- a/src/vimpdb/tests/scripts/wrongserverlist.py +++ b/src/vimpdb/tests/scripts/wrongserverlist.py @@ -1 +1,4 @@ -print "WRONG" +from __future__ import print_function + + +print("WRONG") From c42fbc98a76074db4a72e71aa2f465dfc9143780 Mon Sep 17 00:00:00 2001 From: byronyi Date: Sat, 23 Aug 2014 18:03:48 +0800 Subject: [PATCH 03/16] reorganize package structure --- setup.py | 2 -- {src/vimpdb => vimpdb}/__init__.py | 0 {src/vimpdb => vimpdb}/bbbconfig.py | 0 {src/vimpdb => vimpdb}/config.py | 0 {src/vimpdb => vimpdb}/controller.py | 0 {src/vimpdb => vimpdb}/debugger.py | 0 {src/vimpdb => vimpdb}/errors.py | 0 {src/vimpdb => vimpdb}/proxy.py | 0 {src/vimpdb => vimpdb}/tests/__init__.py | 0 {src/vimpdb => vimpdb}/tests/scripts/compatiblevim.py | 0 {src/vimpdb => vimpdb}/tests/scripts/emptyserverlist.py | 0 {src/vimpdb => vimpdb}/tests/scripts/incompatiblevim.py | 0 {src/vimpdb => vimpdb}/tests/scripts/nopython.py | 0 {src/vimpdb => vimpdb}/tests/scripts/noserver.py | 0 {src/vimpdb => vimpdb}/tests/scripts/returncode.py | 0 {src/vimpdb => vimpdb}/tests/scripts/rightserverlist.py | 0 {src/vimpdb => vimpdb}/tests/scripts/wrongserverlist.py | 0 {src/vimpdb => vimpdb}/tests/test_config.py | 0 {src/vimpdb => vimpdb}/tests/test_proxy.py | 0 {src/vimpdb => vimpdb}/vimpdb.vim | 0 20 files changed, 2 deletions(-) rename {src/vimpdb => vimpdb}/__init__.py (100%) rename {src/vimpdb => vimpdb}/bbbconfig.py (100%) rename {src/vimpdb => vimpdb}/config.py (100%) rename {src/vimpdb => vimpdb}/controller.py (100%) rename {src/vimpdb => vimpdb}/debugger.py (100%) rename {src/vimpdb => vimpdb}/errors.py (100%) rename {src/vimpdb => vimpdb}/proxy.py (100%) rename {src/vimpdb => vimpdb}/tests/__init__.py (100%) rename {src/vimpdb => vimpdb}/tests/scripts/compatiblevim.py (100%) rename {src/vimpdb => vimpdb}/tests/scripts/emptyserverlist.py (100%) rename {src/vimpdb => vimpdb}/tests/scripts/incompatiblevim.py (100%) rename {src/vimpdb => vimpdb}/tests/scripts/nopython.py (100%) rename {src/vimpdb => vimpdb}/tests/scripts/noserver.py (100%) rename {src/vimpdb => vimpdb}/tests/scripts/returncode.py (100%) rename {src/vimpdb => vimpdb}/tests/scripts/rightserverlist.py (100%) rename {src/vimpdb => vimpdb}/tests/scripts/wrongserverlist.py (100%) rename {src/vimpdb => vimpdb}/tests/test_config.py (100%) rename {src/vimpdb => vimpdb}/tests/test_proxy.py (100%) rename {src/vimpdb => vimpdb}/vimpdb.vim (100%) diff --git a/setup.py b/setup.py index 59b8465..b5859e7 100644 --- a/setup.py +++ b/setup.py @@ -25,8 +25,6 @@ author_email='gotcha@bubblenet.be', url='http://github.com/gotcha/vimpdb', license='MIT', - packages=find_packages('src'), - package_dir={'': 'src'}, include_package_data=True, zip_safe=False, install_requires=[ diff --git a/src/vimpdb/__init__.py b/vimpdb/__init__.py similarity index 100% rename from src/vimpdb/__init__.py rename to vimpdb/__init__.py diff --git a/src/vimpdb/bbbconfig.py b/vimpdb/bbbconfig.py similarity index 100% rename from src/vimpdb/bbbconfig.py rename to vimpdb/bbbconfig.py diff --git a/src/vimpdb/config.py b/vimpdb/config.py similarity index 100% rename from src/vimpdb/config.py rename to vimpdb/config.py diff --git a/src/vimpdb/controller.py b/vimpdb/controller.py similarity index 100% rename from src/vimpdb/controller.py rename to vimpdb/controller.py diff --git a/src/vimpdb/debugger.py b/vimpdb/debugger.py similarity index 100% rename from src/vimpdb/debugger.py rename to vimpdb/debugger.py diff --git a/src/vimpdb/errors.py b/vimpdb/errors.py similarity index 100% rename from src/vimpdb/errors.py rename to vimpdb/errors.py diff --git a/src/vimpdb/proxy.py b/vimpdb/proxy.py similarity index 100% rename from src/vimpdb/proxy.py rename to vimpdb/proxy.py diff --git a/src/vimpdb/tests/__init__.py b/vimpdb/tests/__init__.py similarity index 100% rename from src/vimpdb/tests/__init__.py rename to vimpdb/tests/__init__.py diff --git a/src/vimpdb/tests/scripts/compatiblevim.py b/vimpdb/tests/scripts/compatiblevim.py similarity index 100% rename from src/vimpdb/tests/scripts/compatiblevim.py rename to vimpdb/tests/scripts/compatiblevim.py diff --git a/src/vimpdb/tests/scripts/emptyserverlist.py b/vimpdb/tests/scripts/emptyserverlist.py similarity index 100% rename from src/vimpdb/tests/scripts/emptyserverlist.py rename to vimpdb/tests/scripts/emptyserverlist.py diff --git a/src/vimpdb/tests/scripts/incompatiblevim.py b/vimpdb/tests/scripts/incompatiblevim.py similarity index 100% rename from src/vimpdb/tests/scripts/incompatiblevim.py rename to vimpdb/tests/scripts/incompatiblevim.py diff --git a/src/vimpdb/tests/scripts/nopython.py b/vimpdb/tests/scripts/nopython.py similarity index 100% rename from src/vimpdb/tests/scripts/nopython.py rename to vimpdb/tests/scripts/nopython.py diff --git a/src/vimpdb/tests/scripts/noserver.py b/vimpdb/tests/scripts/noserver.py similarity index 100% rename from src/vimpdb/tests/scripts/noserver.py rename to vimpdb/tests/scripts/noserver.py diff --git a/src/vimpdb/tests/scripts/returncode.py b/vimpdb/tests/scripts/returncode.py similarity index 100% rename from src/vimpdb/tests/scripts/returncode.py rename to vimpdb/tests/scripts/returncode.py diff --git a/src/vimpdb/tests/scripts/rightserverlist.py b/vimpdb/tests/scripts/rightserverlist.py similarity index 100% rename from src/vimpdb/tests/scripts/rightserverlist.py rename to vimpdb/tests/scripts/rightserverlist.py diff --git a/src/vimpdb/tests/scripts/wrongserverlist.py b/vimpdb/tests/scripts/wrongserverlist.py similarity index 100% rename from src/vimpdb/tests/scripts/wrongserverlist.py rename to vimpdb/tests/scripts/wrongserverlist.py diff --git a/src/vimpdb/tests/test_config.py b/vimpdb/tests/test_config.py similarity index 100% rename from src/vimpdb/tests/test_config.py rename to vimpdb/tests/test_config.py diff --git a/src/vimpdb/tests/test_proxy.py b/vimpdb/tests/test_proxy.py similarity index 100% rename from src/vimpdb/tests/test_proxy.py rename to vimpdb/tests/test_proxy.py diff --git a/src/vimpdb/vimpdb.vim b/vimpdb/vimpdb.vim similarity index 100% rename from src/vimpdb/vimpdb.vim rename to vimpdb/vimpdb.vim From f9f3a33be2e60020f570bee548c34a824bd53451 Mon Sep 17 00:00:00 2001 From: byronyi Date: Sat, 23 Aug 2014 18:07:27 +0800 Subject: [PATCH 04/16] py3 supported? --- vimpdb/proxy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vimpdb/proxy.py b/vimpdb/proxy.py index 342a64b..7b72908 100755 --- a/vimpdb/proxy.py +++ b/vimpdb/proxy.py @@ -36,7 +36,7 @@ def _remote_expr(self, expr): raise errors.RemoteUnavailable() child_stdout = p.stdout output = child_stdout.read() - return output.strip() + return output.decode().strip() def _send(self, command): # add ':' to hide last keys sent in VIM command-line @@ -147,7 +147,7 @@ def waitFor(self, pdb): self.bindSocket() (message, address) = self.socket.recvfrom(self.BUFLEN) config.logger.debug("command: %s" % message) - return message + return message.decode() # code leftover from hacking From 7bfde9fb5d9b359ac647b1952da73972d6401c62 Mon Sep 17 00:00:00 2001 From: byronyi Date: Sat, 23 Aug 2014 18:14:44 +0800 Subject: [PATCH 05/16] update readme --- README.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.rst b/README.rst index 1ab0a88..07bc03c 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,19 @@ VIM Pdb integration =================== +Latest + +Use ``pip3 install git+https://github.com/byronyi/vimpdb`` to install the +package. + +Use ``python setup.py test`` to test the package if you would like to participate in the +development. (Requires package ``pytest``) + +This package is awesome but not active since 2011. Let's port it into py3k! + + +.. contents:: + Abstract ======== From 68274f2b5ac5b04815f673545e9dafa0ab838842 Mon Sep 17 00:00:00 2001 From: Byron Yi Date: Sat, 23 Aug 2014 18:23:02 +0800 Subject: [PATCH 06/16] Update README.rst --- README.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 07bc03c..3bcedb3 100644 --- a/README.rst +++ b/README.rst @@ -7,9 +7,8 @@ Latest Use ``pip3 install git+https://github.com/byronyi/vimpdb`` to install the package. -Use ``python setup.py test`` to test the package if you would like to participate in the -development. (Requires package ``pytest``) - +Use ``python setup.py test`` to test the package if you would like to +participate in the development. (Requires package ``pytest``) This package is awesome but not active since 2011. Let's port it into py3k! From a13a80bee7850fb6c6c218d9702404c147cbac6c Mon Sep 17 00:00:00 2001 From: byronyi Date: Sat, 23 Aug 2014 18:50:57 +0800 Subject: [PATCH 07/16] add standardized setuptools test --- setup.py | 23 +++++++++++++++++++ {vimpdb/tests => tests}/__init__.py | 0 .../tests => tests}/scripts/compatiblevim.py | 0 .../scripts/emptyserverlist.py | 0 .../scripts/incompatiblevim.py | 0 {vimpdb/tests => tests}/scripts/nopython.py | 0 {vimpdb/tests => tests}/scripts/noserver.py | 0 {vimpdb/tests => tests}/scripts/returncode.py | 0 .../scripts/rightserverlist.py | 0 .../scripts/wrongserverlist.py | 0 {vimpdb/tests => tests}/test_config.py | 0 {vimpdb/tests => tests}/test_proxy.py | 0 12 files changed, 23 insertions(+) rename {vimpdb/tests => tests}/__init__.py (100%) rename {vimpdb/tests => tests}/scripts/compatiblevim.py (100%) rename {vimpdb/tests => tests}/scripts/emptyserverlist.py (100%) rename {vimpdb/tests => tests}/scripts/incompatiblevim.py (100%) rename {vimpdb/tests => tests}/scripts/nopython.py (100%) rename {vimpdb/tests => tests}/scripts/noserver.py (100%) rename {vimpdb/tests => tests}/scripts/returncode.py (100%) rename {vimpdb/tests => tests}/scripts/rightserverlist.py (100%) rename {vimpdb/tests => tests}/scripts/wrongserverlist.py (100%) rename {vimpdb/tests => tests}/test_config.py (100%) rename {vimpdb/tests => tests}/test_proxy.py (100%) diff --git a/setup.py b/setup.py index b5859e7..85e42a9 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,26 @@ from setuptools import setup, find_packages +import sys +from setuptools.command.test import test as TestCommand + + +class PyTest(TestCommand): + user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] + + def initialize_options(self): + TestCommand.initialize_options(self) + self.pytest_args = ['.'] + + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = [] + self.test_suite = True + + def run_tests(self): + #import here, cause outside the eggs aren't loaded + import pytest + errno = pytest.main(self.pytest_args) + sys.exit(errno) + version = '0.4.6dev' @@ -31,6 +53,7 @@ 'vim_bridge', 'six' ], + cmdclass = {'test': PyTest}, entry_points=""" # -*- Entry points: -*- """, diff --git a/vimpdb/tests/__init__.py b/tests/__init__.py similarity index 100% rename from vimpdb/tests/__init__.py rename to tests/__init__.py diff --git a/vimpdb/tests/scripts/compatiblevim.py b/tests/scripts/compatiblevim.py similarity index 100% rename from vimpdb/tests/scripts/compatiblevim.py rename to tests/scripts/compatiblevim.py diff --git a/vimpdb/tests/scripts/emptyserverlist.py b/tests/scripts/emptyserverlist.py similarity index 100% rename from vimpdb/tests/scripts/emptyserverlist.py rename to tests/scripts/emptyserverlist.py diff --git a/vimpdb/tests/scripts/incompatiblevim.py b/tests/scripts/incompatiblevim.py similarity index 100% rename from vimpdb/tests/scripts/incompatiblevim.py rename to tests/scripts/incompatiblevim.py diff --git a/vimpdb/tests/scripts/nopython.py b/tests/scripts/nopython.py similarity index 100% rename from vimpdb/tests/scripts/nopython.py rename to tests/scripts/nopython.py diff --git a/vimpdb/tests/scripts/noserver.py b/tests/scripts/noserver.py similarity index 100% rename from vimpdb/tests/scripts/noserver.py rename to tests/scripts/noserver.py diff --git a/vimpdb/tests/scripts/returncode.py b/tests/scripts/returncode.py similarity index 100% rename from vimpdb/tests/scripts/returncode.py rename to tests/scripts/returncode.py diff --git a/vimpdb/tests/scripts/rightserverlist.py b/tests/scripts/rightserverlist.py similarity index 100% rename from vimpdb/tests/scripts/rightserverlist.py rename to tests/scripts/rightserverlist.py diff --git a/vimpdb/tests/scripts/wrongserverlist.py b/tests/scripts/wrongserverlist.py similarity index 100% rename from vimpdb/tests/scripts/wrongserverlist.py rename to tests/scripts/wrongserverlist.py diff --git a/vimpdb/tests/test_config.py b/tests/test_config.py similarity index 100% rename from vimpdb/tests/test_config.py rename to tests/test_config.py diff --git a/vimpdb/tests/test_proxy.py b/tests/test_proxy.py similarity index 100% rename from vimpdb/tests/test_proxy.py rename to tests/test_proxy.py From 5ec271872cb43abe6b2078835ae04db474fa986a Mon Sep 17 00:00:00 2001 From: byronyi Date: Sat, 23 Aug 2014 19:03:59 +0800 Subject: [PATCH 08/16] add package --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 85e42a9..c2e5c2a 100644 --- a/setup.py +++ b/setup.py @@ -48,11 +48,15 @@ def run_tests(self): url='http://github.com/gotcha/vimpdb', license='MIT', include_package_data=True, + packages=find_packages(), zip_safe=False, install_requires=[ 'vim_bridge', 'six' ], + package_data = { + 'vimpdb': ['vimpdb.vim'] + }, cmdclass = {'test': PyTest}, entry_points=""" # -*- Entry points: -*- From d50c91852fad26031f1eb50e7375daf525f98635 Mon Sep 17 00:00:00 2001 From: Byron Yi Date: Sat, 23 Aug 2014 19:06:42 +0800 Subject: [PATCH 09/16] Update README.rst --- README.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.rst b/README.rst index 3bcedb3..ba58a28 100644 --- a/README.rst +++ b/README.rst @@ -9,8 +9,17 @@ package. Use ``python setup.py test`` to test the package if you would like to participate in the development. (Requires package ``pytest``) + This package is awesome but not active since 2011. Let's port it into py3k! +Remember: put the following config into your ``~/.vimpdbrc``! +:: + [vimpdb] + vim_client_script = mvim + vim_server_script = mvim + server_name = VIM + port = 6666 +:: .. contents:: From 8feb8dc4870a2ac70f9ad2664a8a1e5db4335d27 Mon Sep 17 00:00:00 2001 From: Byron Yi Date: Sat, 23 Aug 2014 19:08:43 +0800 Subject: [PATCH 10/16] Update README.rst --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index ba58a28..c871f4b 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,7 @@ participate in the development. (Requires package ``pytest``) This package is awesome but not active since 2011. Let's port it into py3k! Remember: put the following config into your ``~/.vimpdbrc``! + :: [vimpdb] vim_client_script = mvim @@ -22,6 +23,10 @@ Remember: put the following config into your ``~/.vimpdbrc``! :: .. contents:: +======= + +:: +>>>>>>> Update README.rst Abstract ======== From 6d3b85913d5c881c4e6d11a3689126103139944f Mon Sep 17 00:00:00 2001 From: byronyi Date: Sat, 23 Aug 2014 22:43:40 +0800 Subject: [PATCH 11/16] test passed --- setup.py | 4 ++++ {src/vimpdb/tests => tests}/scripts/communicator.py | 8 ++++++-- {src/vimpdb/tests => tests}/test_debugger.py | 8 ++++++-- vimpdb/debugger.py | 2 +- vimpdb/proxy.py | 9 +++++---- 5 files changed, 22 insertions(+), 9 deletions(-) rename {src/vimpdb/tests => tests}/scripts/communicator.py (66%) rename {src/vimpdb/tests => tests}/test_debugger.py (95%) diff --git a/setup.py b/setup.py index c2e5c2a..a55316e 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,10 @@ def run_tests(self): 'vim_bridge', 'six' ], + tests_require=[ + 'mock', + 'pytest' + ], package_data = { 'vimpdb': ['vimpdb.vim'] }, diff --git a/src/vimpdb/tests/scripts/communicator.py b/tests/scripts/communicator.py similarity index 66% rename from src/vimpdb/tests/scripts/communicator.py rename to tests/scripts/communicator.py index fb9abcf..c8a6a7d 100644 --- a/src/vimpdb/tests/scripts/communicator.py +++ b/tests/scripts/communicator.py @@ -1,5 +1,9 @@ +from __future__ import print_function + import optparse import sys + + parser = optparse.OptionParser() parser.add_option('--servername', dest="server_name") parser.add_option('--remote-expr', dest="expr") @@ -9,6 +13,6 @@ parser.parse_args(sys.argv) if hasattr(parser.values, 'expr'): - print parser.values.expr, parser.values.server_name + print(parser.values.expr, parser.values.server_name) if hasattr(parser.values, 'command'): - print parser.values.command, parser.values.server_name + print(parser.values.command, parser.values.server_name) diff --git a/src/vimpdb/tests/test_debugger.py b/tests/test_debugger.py similarity index 95% rename from src/vimpdb/tests/test_debugger.py rename to tests/test_debugger.py index 8c0805d..d97bb68 100644 --- a/src/vimpdb/tests/test_debugger.py +++ b/tests/test_debugger.py @@ -49,7 +49,12 @@ def test_hook(mocked_trace_dispatch): from vimpdb.debugger import hook from vimpdb.debugger import SwitcherToVimpdb - class Klass: + # A work around for Python bug: + # http://bugs.python.org/issue672115 + class Base(object): + pass + + class Klass(Base): def trace_dispatch(self): pass @@ -74,7 +79,6 @@ class Klass: def do_vim(self): pass - hook(Klass) assert not mocked_setupMethod.called diff --git a/vimpdb/debugger.py b/vimpdb/debugger.py index 5cc36b3..a9dd9f9 100755 --- a/vimpdb/debugger.py +++ b/vimpdb/debugger.py @@ -286,7 +286,7 @@ def hook(klass): if not hasattr(klass, 'do_vim'): setupMethod(klass, trace_dispatch) - klass.__bases__ += (SwitcherToVimpdb, ) + klass.__bases__ = (SwitcherToVimpdb, ) + klass.__bases__ def get_hooked_pdb(): diff --git a/vimpdb/proxy.py b/vimpdb/proxy.py index 7b72908..e9ec9b2 100755 --- a/vimpdb/proxy.py +++ b/vimpdb/proxy.py @@ -29,7 +29,7 @@ def prepare_subprocess(self, *args): def _remote_expr(self, expr): parts = self.prepare_subprocess('--servername', - self.server_name, "--remote-expr", expr) + self.server_name, "--remote-expr", expr) p = subprocess.Popen(parts, stdout=subprocess.PIPE) return_code = p.wait() if return_code: @@ -42,7 +42,8 @@ def _send(self, command): # add ':' to hide last keys sent in VIM command-line command = ''.join((command, ':')) parts = self.prepare_subprocess('--servername', - self.server_name, "--remote-send", command) + self.server_name, + "--remote-send", command) return_code = subprocess.call(parts) if return_code: raise errors.RemoteUnavailable() @@ -106,7 +107,7 @@ def _showFileAtLine(self, filename, lineno): filename = filename.replace('\\', '/') self.setupRemote() self._send(':call PDB_show_file_at_line("%s", "%d")' - % (filename, lineno)) + % (filename, lineno)) def _expr(self, expr): config.logger.debug("expr: %s" % expr) @@ -147,7 +148,7 @@ def waitFor(self, pdb): self.bindSocket() (message, address) = self.socket.recvfrom(self.BUFLEN) config.logger.debug("command: %s" % message) - return message.decode() + return message # code leftover from hacking From 99c8b323e1a0df63f44323ce2e3f5e00fa59a148 Mon Sep 17 00:00:00 2001 From: byronyi Date: Sat, 23 Aug 2014 22:45:42 +0800 Subject: [PATCH 12/16] set up travis-ci --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5e562a0..c668537 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,9 @@ language: python python: - - 2.5 - - 2.6 - 2.7 + - 3.4 # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: - pip install . --use-mirrors # command to run tests, e.g. python setup.py test -script: py.test . - +script: python setup.py test From ed101a2a83a4637122c63b6ecc2665c63ebda83c Mon Sep 17 00:00:00 2001 From: byronyi Date: Mon, 25 Aug 2014 11:24:55 +0800 Subject: [PATCH 13/16] fix --- vimpdb/debugger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vimpdb/debugger.py b/vimpdb/debugger.py index a9dd9f9..ac2f6d6 100755 --- a/vimpdb/debugger.py +++ b/vimpdb/debugger.py @@ -133,7 +133,7 @@ def showFileAtLine(self): def formatLocals(self): stream = StringIO() locals = self.curframe.f_locals - keys = locals.keys() + keys = list(locals.keys()) keys.sort() for key in keys: stream.write('%s = \n' % key) @@ -218,7 +218,7 @@ def default(self, line): def make_instance(): configuration = config.get_configuration() communicator = proxy.Communicator(configuration.vim_client_script, - configuration.server_name) + configuration.server_name) to_vim = proxy.ProxyToVim(communicator) from_vim = proxy.ProxyFromVim(configuration.port) return VimPdb(to_vim, from_vim) From 229484ab92bee783e51e5f1320062bd43d460481 Mon Sep 17 00:00:00 2001 From: byronyi Date: Mon, 25 Aug 2014 14:46:53 +0800 Subject: [PATCH 14/16] fix py3 err with bytes --- vimpdb/debugger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vimpdb/debugger.py b/vimpdb/debugger.py index ac2f6d6..01d74e3 100755 --- a/vimpdb/debugger.py +++ b/vimpdb/debugger.py @@ -110,7 +110,7 @@ def cmdloop(self): stop = None self.preloop() while not stop: - line = self.from_vim.waitFor(self) + line = self.from_vim.waitFor(self).decode() line = self.precmd(line) stop = self.onecmd(line) stop = self.postcmd(stop, line) From c41e6fb8794bc97f4ca3eac6509686219e8467c0 Mon Sep 17 00:00:00 2001 From: byronyi Date: Mon, 25 Aug 2014 14:59:01 +0800 Subject: [PATCH 15/16] fix readme --- README.rst | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.rst b/README.rst index c871f4b..0cd2129 100644 --- a/README.rst +++ b/README.rst @@ -20,13 +20,6 @@ Remember: put the following config into your ``~/.vimpdbrc``! vim_server_script = mvim server_name = VIM port = 6666 -:: - -.. contents:: -======= - -:: ->>>>>>> Update README.rst Abstract ======== From 13dd2ed618adc33addf46ec5410a2bcaa04a0165 Mon Sep 17 00:00:00 2001 From: Byron Yi Date: Mon, 25 Aug 2014 15:03:23 +0800 Subject: [PATCH 16/16] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 0cd2129..589dcab 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,7 @@ VIM Pdb integration Latest + Use ``pip3 install git+https://github.com/byronyi/vimpdb`` to install the package. @@ -13,7 +14,6 @@ participate in the development. (Requires package ``pytest``) This package is awesome but not active since 2011. Let's port it into py3k! Remember: put the following config into your ``~/.vimpdbrc``! - :: [vimpdb] vim_client_script = mvim