From 2c7aa8adc5fc37f49d0735ac38dc94341252d735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20M=C3=A5s=C3=A9n?= Date: Mon, 8 Jun 2020 20:59:59 +0200 Subject: [PATCH] upgrade to python3 --- plugin/vimbits.vim | 2 +- rplugin/{python => python3}/floobits.py | 0 .../{python => python3}/floobits/__init__.py | 30 +++++++++---------- .../{python => python3}/floobits/common/.floo | 0 .../floobits/common/.flooignore | 0 .../floobits/common/.gitignore | 0 .../floobits/common/LICENSE | 0 .../floobits/common/NOTICE | 0 .../floobits/common/README.md | 0 .../floobits/common/__init__.py | 0 .../floobits/common/api.py | 22 +++++++------- .../floobits/common/cert.py | 0 .../floobits/common/event_emitter.py | 0 .../floobits/common/exc_fmt.py | 10 +++---- .../floobits/common/flooui.py | 8 ++--- .../floobits/common/handlers/__init__.py | 0 .../floobits/common/handlers/account.py | 2 +- .../floobits/common/handlers/base.py | 0 .../floobits/common/handlers/credentials.py | 4 +-- .../floobits/common/handlers/floo_handler.py | 16 +++++----- .../floobits/common/handlers/tcp_server.py | 2 +- .../floobits/common/ignore.py | 10 +++---- .../floobits/common/lib/__init__.py | 4 +-- .../floobits/common/lib/diff_match_patch.py | 12 ++++---- .../floobits/common/lib/dmp_monkey.py | 0 .../floobits/common/msg.py | 18 +++++------ .../floobits/common/protocols/__init__.py | 0 .../floobits/common/protocols/base.py | 0 .../floobits/common/protocols/floo_proto.py | 4 +-- .../floobits/common/protocols/no_reconnect.py | 2 +- .../floobits/common/protocols/proxy.py | 0 .../floobits/common/protocols/tcp_server.py | 2 +- .../floobits/common/proxy.py | 12 ++++---- .../floobits/common/reactor.py | 0 .../floobits/common/repo.py | 10 +++---- .../floobits/common/shared.py | 0 .../floobits/common/utils.py | 28 ++++++++--------- .../{python => python3}/floobits/editor.py | 2 +- rplugin/{python => python3}/floobits/view.py | 6 ++-- .../floobits/vim_handler.py | 16 +++++----- rplugin/{python => python3}/floobits/vui.py | 8 ++--- 41 files changed, 115 insertions(+), 115 deletions(-) rename rplugin/{python => python3}/floobits.py (100%) rename rplugin/{python => python3}/floobits/__init__.py (95%) rename rplugin/{python => python3}/floobits/common/.floo (100%) rename rplugin/{python => python3}/floobits/common/.flooignore (100%) rename rplugin/{python => python3}/floobits/common/.gitignore (100%) rename rplugin/{python => python3}/floobits/common/LICENSE (100%) rename rplugin/{python => python3}/floobits/common/NOTICE (100%) rename rplugin/{python => python3}/floobits/common/README.md (100%) rename rplugin/{python => python3}/floobits/common/__init__.py (100%) rename rplugin/{python => python3}/floobits/common/api.py (94%) rename rplugin/{python => python3}/floobits/common/cert.py (100%) rename rplugin/{python => python3}/floobits/common/event_emitter.py (100%) rename rplugin/{python => python3}/floobits/common/exc_fmt.py (84%) rename rplugin/{python => python3}/floobits/common/flooui.py (99%) rename rplugin/{python => python3}/floobits/common/handlers/__init__.py (100%) rename rplugin/{python => python3}/floobits/common/handlers/account.py (99%) rename rplugin/{python => python3}/floobits/common/handlers/base.py (100%) rename rplugin/{python => python3}/floobits/common/handlers/credentials.py (97%) rename rplugin/{python => python3}/floobits/common/handlers/floo_handler.py (98%) rename rplugin/{python => python3}/floobits/common/handlers/tcp_server.py (95%) rename rplugin/{python => python3}/floobits/common/ignore.py (97%) rename rplugin/{python => python3}/floobits/common/lib/__init__.py (74%) rename rplugin/{python => python3}/floobits/common/lib/diff_match_patch.py (99%) rename rplugin/{python => python3}/floobits/common/lib/dmp_monkey.py (100%) rename rplugin/{python => python3}/floobits/common/msg.py (87%) rename rplugin/{python => python3}/floobits/common/protocols/__init__.py (100%) rename rplugin/{python => python3}/floobits/common/protocols/base.py (100%) rename rplugin/{python => python3}/floobits/common/protocols/floo_proto.py (99%) rename rplugin/{python => python3}/floobits/common/protocols/no_reconnect.py (97%) rename rplugin/{python => python3}/floobits/common/protocols/proxy.py (100%) rename rplugin/{python => python3}/floobits/common/protocols/tcp_server.py (97%) rename rplugin/{python => python3}/floobits/common/proxy.py (91%) rename rplugin/{python => python3}/floobits/common/reactor.py (100%) rename rplugin/{python => python3}/floobits/common/repo.py (92%) rename rplugin/{python => python3}/floobits/common/shared.py (100%) rename rplugin/{python => python3}/floobits/common/utils.py (96%) rename rplugin/{python => python3}/floobits/editor.py (98%) rename rplugin/{python => python3}/floobits/view.py (98%) rename rplugin/{python => python3}/floobits/vim_handler.py (98%) rename rplugin/{python => python3}/floobits/vui.py (95%) diff --git a/plugin/vimbits.vim b/plugin/vimbits.vim index d9fcde0..d5890e7 100644 --- a/plugin/vimbits.vim +++ b/plugin/vimbits.vim @@ -1,7 +1,7 @@ " Copyright 2014-2017 Floobits, Inc -if !has('python') +if !has('python3') echomsg "Floobits error: no neovim python module. Run `pip install neovim` to fix. For more info, :he nvim-python" endif diff --git a/rplugin/python/floobits.py b/rplugin/python3/floobits.py similarity index 100% rename from rplugin/python/floobits.py rename to rplugin/python3/floobits.py diff --git a/rplugin/python/floobits/__init__.py b/rplugin/python3/floobits/__init__.py similarity index 95% rename from rplugin/python/floobits/__init__.py rename to rplugin/python3/floobits/__init__.py index d9ef9e8..ced045d 100644 --- a/rplugin/python/floobits/__init__.py +++ b/rplugin/python3/floobits/__init__.py @@ -9,12 +9,12 @@ import neovim try: - unicode() + str() except NameError: - unicode = str + str = str try: - import urllib + import urllib.request, urllib.parse, urllib.error urllib = imp.reload(urllib) from urllib import request request = imp.reload(request) @@ -24,19 +24,19 @@ URLError = urllib.error.URLError assert Request and urlopen and HTTPError and URLError except ImportError: - import urllib2 + import urllib.request, urllib.error, urllib.parse urllib2 = imp.reload(urllib2) - Request = urllib2.Request - urlopen = urllib2.urlopen - HTTPError = urllib2.HTTPError - URLError = urllib2.URLError + Request = urllib.request.Request + urlopen = urllib.request.urlopen + HTTPError = urllib.error.HTTPError + URLError = urllib.error.URLError -from common import api, msg, reactor, utils, shared as G -import editor -import vui -import view -import vim_handler +from .common import api, msg, reactor, utils, shared as G +from . import editor +from . import vui +from . import view +from . import vim_handler VUI = vui.VUI() @@ -266,7 +266,7 @@ def users_in_workspace(self): if not G.AGENT: return msg.warn('Not connected to a workspace.') self.vim.command('echom "Users connected to %s"' % (G.AGENT.workspace,)) - for user in G.AGENT.workspace_info['users'].values(): + for user in list(G.AGENT.workspace_info['users'].values()): self.vim.command('echom " %s connected with %s on %s"' % (user['username'], user['client'], user['platform'])) @neovim.command('FlooListMessages', sync=True) @@ -296,7 +296,7 @@ def buf_enter(self): except Exception as e: msg.debug('Error running on_load patch handler for buf %s: %s' % (buf_id, str(e))) # NOTE: we call highlight twice in follow mode... thats stupid - for user_id, highlight in G.AGENT.user_highlights.items(): + for user_id, highlight in list(G.AGENT.user_highlights.items()): if highlight['id'] == buf_id: G.AGENT._on_highlight(highlight) diff --git a/rplugin/python/floobits/common/.floo b/rplugin/python3/floobits/common/.floo similarity index 100% rename from rplugin/python/floobits/common/.floo rename to rplugin/python3/floobits/common/.floo diff --git a/rplugin/python/floobits/common/.flooignore b/rplugin/python3/floobits/common/.flooignore similarity index 100% rename from rplugin/python/floobits/common/.flooignore rename to rplugin/python3/floobits/common/.flooignore diff --git a/rplugin/python/floobits/common/.gitignore b/rplugin/python3/floobits/common/.gitignore similarity index 100% rename from rplugin/python/floobits/common/.gitignore rename to rplugin/python3/floobits/common/.gitignore diff --git a/rplugin/python/floobits/common/LICENSE b/rplugin/python3/floobits/common/LICENSE similarity index 100% rename from rplugin/python/floobits/common/LICENSE rename to rplugin/python3/floobits/common/LICENSE diff --git a/rplugin/python/floobits/common/NOTICE b/rplugin/python3/floobits/common/NOTICE similarity index 100% rename from rplugin/python/floobits/common/NOTICE rename to rplugin/python3/floobits/common/NOTICE diff --git a/rplugin/python/floobits/common/README.md b/rplugin/python3/floobits/common/README.md similarity index 100% rename from rplugin/python/floobits/common/README.md rename to rplugin/python3/floobits/common/README.md diff --git a/rplugin/python/floobits/common/__init__.py b/rplugin/python3/floobits/common/__init__.py similarity index 100% rename from rplugin/python/floobits/common/__init__.py rename to rplugin/python3/floobits/common/__init__.py diff --git a/rplugin/python/floobits/common/api.py b/rplugin/python3/floobits/common/api.py similarity index 94% rename from rplugin/python/floobits/common/api.py rename to rplugin/python3/floobits/common/api.py index f78b8b6..85c97fd 100644 --- a/rplugin/python/floobits/common/api.py +++ b/rplugin/python3/floobits/common/api.py @@ -15,31 +15,31 @@ try: - import __builtin__ - str_instances = (str, __builtin__.basestring) + import builtins + str_instances = (str, builtins.str) except Exception: str_instances = (str, ) try: - import urllib + import urllib.request, urllib.parse, urllib.error from urllib.request import Request, urlopen HTTPError = urllib.error.HTTPError URLError = urllib.error.URLError except (AttributeError, ImportError, ValueError): - import urllib2 - from urllib2 import Request, urlopen - HTTPError = urllib2.HTTPError - URLError = urllib2.URLError + import urllib.request, urllib.error, urllib.parse + from urllib.request import Request, urlopen + HTTPError = urllib.error.HTTPError + URLError = urllib.error.URLError try: from .. import editor from . import cert, msg, shared as G, utils except ImportError: - import cert + from . import cert import editor - import msg - import shared as G - import utils + from . import msg + from . import shared as G + from . import utils def get_basic_auth(host): diff --git a/rplugin/python/floobits/common/cert.py b/rplugin/python3/floobits/common/cert.py similarity index 100% rename from rplugin/python/floobits/common/cert.py rename to rplugin/python3/floobits/common/cert.py diff --git a/rplugin/python/floobits/common/event_emitter.py b/rplugin/python3/floobits/common/event_emitter.py similarity index 100% rename from rplugin/python/floobits/common/event_emitter.py rename to rplugin/python3/floobits/common/event_emitter.py diff --git a/rplugin/python/floobits/common/exc_fmt.py b/rplugin/python3/floobits/common/exc_fmt.py similarity index 84% rename from rplugin/python/floobits/common/exc_fmt.py rename to rplugin/python3/floobits/common/exc_fmt.py index 5767880..7519538 100644 --- a/rplugin/python/floobits/common/exc_fmt.py +++ b/rplugin/python3/floobits/common/exc_fmt.py @@ -5,19 +5,19 @@ import traceback try: - unicode() + str() except NameError: - unicode = None + str = None def str_e(e): with warnings.catch_warnings(): warnings.simplefilter("ignore") message = getattr(e, "message", None) - if not (message and unicode): + if not (message and str): return str(e) try: - return unicode(message, "utf8").encode("utf8") + return str(message, "utf8").encode("utf8") except: return message.encode("utf8") @@ -55,7 +55,7 @@ def test2(excp): assert isinstance(stre, str) print(stre) - tests = [Exception("asdf"), Exception(u"aß∂ƒ"), Exception(u"asdf"), Exception(b"asdf1234")] + tests = [Exception("asdf"), Exception("aß∂ƒ"), Exception("asdf"), Exception(b"asdf1234")] for t in tests: test(t) if getattr(sys, "exc_clear", None): diff --git a/rplugin/python/floobits/common/flooui.py b/rplugin/python3/floobits/common/flooui.py similarity index 99% rename from rplugin/python/floobits/common/flooui.py rename to rplugin/python3/floobits/common/flooui.py index 7b61adb..b73f2d5 100644 --- a/rplugin/python/floobits/common/flooui.py +++ b/rplugin/python3/floobits/common/flooui.py @@ -62,7 +62,7 @@ def link_account(self, context, host, cb): try: reactor.reactor.connect(agent, host, G.DEFAULT_PORT, True) except Exception as e: - print(str_e(e)) + print((str_e(e))) @utils.inlined_callbacks def create_or_link_account(self, context, host, force, cb): @@ -106,7 +106,7 @@ def create_or_link_account(self, context, host, force, cb): try: reactor.reactor.connect(agent, host, G.DEFAULT_PORT, True) except Exception as e: - print(str_e(e)) + print((str_e(e))) def open_workspace(self): if not self.agent: @@ -295,7 +295,7 @@ def follow_user(self, context, cb=None): users = self.agent.workspace_info.get('users') userNames = set() me = self.agent.get_username_by_id(self.agent.workspace_info['user_id']) - for user in users.values(): + for user in list(users.values()): username = user['username'] if username == me: continue @@ -479,7 +479,7 @@ def _get_host(self, context, cb): if len(hosts) == 1: host = hosts[0] else: - little = ["%s on %s" % (a['username'], h) for h, a in G.AUTH.items()] + little = ["%s on %s" % (a['username'], h) for h, a in list(G.AUTH.items())] (host, index) = yield self.user_select, context, 'Which Floobits account should be used?', hosts, little if not host: cb(None) diff --git a/rplugin/python/floobits/common/handlers/__init__.py b/rplugin/python3/floobits/common/handlers/__init__.py similarity index 100% rename from rplugin/python/floobits/common/handlers/__init__.py rename to rplugin/python3/floobits/common/handlers/__init__.py diff --git a/rplugin/python/floobits/common/handlers/account.py b/rplugin/python3/floobits/common/handlers/account.py similarity index 99% rename from rplugin/python/floobits/common/handlers/account.py rename to rplugin/python3/floobits/common/handlers/account.py index de75496..8a42045 100644 --- a/rplugin/python/floobits/common/handlers/account.py +++ b/rplugin/python3/floobits/common/handlers/account.py @@ -11,7 +11,7 @@ from ..protocols import no_reconnect assert api and G and msg and utils except (ImportError, ValueError): - import base + from . import base from floo import editor from floo.common.protocols import no_reconnect from floo.common.exc_fmt import str_e diff --git a/rplugin/python/floobits/common/handlers/base.py b/rplugin/python3/floobits/common/handlers/base.py similarity index 100% rename from rplugin/python/floobits/common/handlers/base.py rename to rplugin/python3/floobits/common/handlers/base.py diff --git a/rplugin/python/floobits/common/handlers/credentials.py b/rplugin/python3/floobits/common/handlers/credentials.py similarity index 97% rename from rplugin/python/floobits/common/handlers/credentials.py rename to rplugin/python3/floobits/common/handlers/credentials.py index f7adcbf..5370752 100644 --- a/rplugin/python/floobits/common/handlers/credentials.py +++ b/rplugin/python3/floobits/common/handlers/credentials.py @@ -12,7 +12,7 @@ from ..protocols import no_reconnect assert api and G and utils except (ImportError, ValueError): - import base + from . import base from floo import editor from floo.common.protocols import no_reconnect from floo.common.exc_fmt import str_e @@ -71,4 +71,4 @@ def _on_credentials(self, data): try: self.stop() except Exception as e: - print(str_e(e)) + print((str_e(e))) diff --git a/rplugin/python/floobits/common/handlers/floo_handler.py b/rplugin/python3/floobits/common/handlers/floo_handler.py similarity index 98% rename from rplugin/python/floobits/common/handlers/floo_handler.py rename to rplugin/python3/floobits/common/handlers/floo_handler.py index 1acf0dd..60ee492 100644 --- a/rplugin/python/floobits/common/handlers/floo_handler.py +++ b/rplugin/python3/floobits/common/handlers/floo_handler.py @@ -15,7 +15,7 @@ from ... import editor from ..protocols import floo_proto except (ImportError, ValueError) as e: - import base + from . import base from floo import editor from floo.common.lib import DMP from floo.common.reactor import reactor @@ -24,9 +24,9 @@ from floo.common.protocols import floo_proto try: - unicode() + str() except NameError: - unicode = str + str = str try: import io @@ -328,7 +328,7 @@ def _initial_upload(self, ig, missing_bufs, changed_bufs, cb): for buf_id in missing_buf_ids: self.send({'name': 'delete_buf', 'id': buf_id}) - for p, buf_id in self.paths_to_ids.items(): + for p, buf_id in list(self.paths_to_ids.items()): if p in files: files.discard(p) # TODO: recalculate size (need size in room_info) @@ -372,7 +372,7 @@ def _scan_dir(self, bufs, ig, read_only): if not read_only: new_files = set([utils.to_rel_path(x) for x in ig.list_paths()]) - for buf_id, buf in bufs.items(): + for buf_id, buf in list(bufs.items()): buf_id = int(buf_id) # json keys must be strings buf_path = utils.get_full_path(buf['path']) view = self.get_view(buf_id) @@ -456,14 +456,14 @@ def _on_room_info(self, data): ig = ignore.create_ignore_tree(G.PROJECT_PATH) G.IGNORE = ig - for buf_id, buf in data['bufs'].items(): + for buf_id, buf in list(data['bufs'].items()): buf_id = int(buf_id) # json keys must be strings self.bufs[buf_id] = buf self.paths_to_ids[buf['path']] = buf_id changed_bufs, missing_bufs, new_files = self._scan_dir(data['bufs'], ig, read_only) ignored = [] - for p, buf_id in self.paths_to_ids.items(): + for p, buf_id in list(self.paths_to_ids.items()): if p not in new_files: ignored.append(p) new_files.discard(p) @@ -540,7 +540,7 @@ def refresh_workspace(self): read_only = 'patch' not in self.workspace_info['perms'] changed_bufs, missing_bufs, new_files = self._scan_dir(self.bufs, G.IGNORE, read_only) ignored = [] - for p, buf_id in self.paths_to_ids.items(): + for p, buf_id in list(self.paths_to_ids.items()): if p not in new_files: ignored.append(p) new_files.discard(p) diff --git a/rplugin/python/floobits/common/handlers/tcp_server.py b/rplugin/python3/floobits/common/handlers/tcp_server.py similarity index 95% rename from rplugin/python/floobits/common/handlers/tcp_server.py rename to rplugin/python3/floobits/common/handlers/tcp_server.py index 0c2236c..04e51db 100644 --- a/rplugin/python/floobits/common/handlers/tcp_server.py +++ b/rplugin/python3/floobits/common/handlers/tcp_server.py @@ -4,7 +4,7 @@ from .. protocols import tcp_server except (ImportError, ValueError): from floo.common.protocols import tcp_server - import base + from . import base class TCPServerHandler(base.BaseHandler): diff --git a/rplugin/python/floobits/common/ignore.py b/rplugin/python3/floobits/common/ignore.py similarity index 97% rename from rplugin/python/floobits/common/ignore.py rename to rplugin/python3/floobits/common/ignore.py index 5a9b4b7..04dfb09 100644 --- a/rplugin/python/floobits/common/ignore.py +++ b/rplugin/python3/floobits/common/ignore.py @@ -9,8 +9,8 @@ from .exc_fmt import str_e assert msg and str_e and utils except ImportError: - import msg - from exc_fmt import str_e + from . import msg + from .exc_fmt import str_e IGNORE_FILES = ['.gitignore', '.hgignore', '.ignore', '.flooignore'] HIDDEN_WHITELIST = ['.floo'] + IGNORE_FILES @@ -166,14 +166,14 @@ def load(self, ignore_file): def get_children(self): children = list(self.children.values()) - for c in self.children.values(): + for c in list(self.children.values()): children += c.get_children() return children def list_paths(self): for f in self.files: yield os.path.join(self.path, f) - for c in self.children.values(): + for c in list(self.children.values()): for p in c.list_paths(): yield p @@ -203,7 +203,7 @@ def _is_ignored(self, rel_path, is_dir, log): if not is_dir and file_name in HIDDEN_WHITELIST: return False - for ignore_file, patterns in self.ignores.items(): + for ignore_file, patterns in list(self.ignores.items()): for pattern in patterns: orig_pattern = pattern negate = False diff --git a/rplugin/python/floobits/common/lib/__init__.py b/rplugin/python3/floobits/common/lib/__init__.py similarity index 74% rename from rplugin/python/floobits/common/lib/__init__.py rename to rplugin/python3/floobits/common/lib/__init__.py index 4757495..380ef84 100644 --- a/rplugin/python/floobits/common/lib/__init__.py +++ b/rplugin/python3/floobits/common/lib/__init__.py @@ -1,13 +1,13 @@ try: from . import dmp_monkey except ImportError: - import dmp_monkey + from . import dmp_monkey dmp_monkey.monkey_patch() try: from . import diff_match_patch except ImportError: - import diff_match_patch + from . import diff_match_patch DMP = diff_match_patch.diff_match_patch() diff --git a/rplugin/python/floobits/common/lib/diff_match_patch.py b/rplugin/python3/floobits/common/lib/diff_match_patch.py similarity index 99% rename from rplugin/python/floobits/common/lib/diff_match_patch.py rename to rplugin/python3/floobits/common/lib/diff_match_patch.py index e8d5bfb..04a091a 100644 --- a/rplugin/python/floobits/common/lib/diff_match_patch.py +++ b/rplugin/python3/floobits/common/lib/diff_match_patch.py @@ -36,15 +36,15 @@ def unquote_py3(x): return parse.unquote(x) unquote = unquote_py3 str_instances = str - unichr = chr + chr = chr except ImportError: import urllib as parse def unquote_py2(x): return parse.unquote(x.encode('utf-8')).decode('utf-8') unquote = unquote_py2 - import __builtin__ - str_instances = (str, __builtin__.basestring) + import builtins + str_instances = (str, builtins.str) class diff_match_patch: @@ -439,11 +439,11 @@ def diff_linesToCharsMunge(text): lineStart = lineEnd + 1 if line in lineHash: - chars.append(unichr(lineHash[line])) + chars.append(chr(lineHash[line])) else: lineArray.append(line) lineHash[line] = len(lineArray) - 1 - chars.append(unichr(len(lineArray) - 1)) + chars.append(chr(len(lineArray) - 1)) return "".join(chars) chars1 = diff_linesToCharsMunge(text1) @@ -1642,7 +1642,7 @@ def patch_addPadding(self, patches): paddingLength = self.Patch_Margin nullPadding = "" for x in range(1, paddingLength + 1): - nullPadding += unichr(x) + nullPadding += chr(x) # Bump all the patches forward. for patch in patches: diff --git a/rplugin/python/floobits/common/lib/dmp_monkey.py b/rplugin/python3/floobits/common/lib/dmp_monkey.py similarity index 100% rename from rplugin/python/floobits/common/lib/dmp_monkey.py rename to rplugin/python3/floobits/common/lib/dmp_monkey.py diff --git a/rplugin/python/floobits/common/msg.py b/rplugin/python3/floobits/common/msg.py similarity index 87% rename from rplugin/python/floobits/common/msg.py rename to rplugin/python3/floobits/common/msg.py index c9fb2f0..d99ab13 100644 --- a/rplugin/python/floobits/common/msg.py +++ b/rplugin/python3/floobits/common/msg.py @@ -4,13 +4,13 @@ try: from . import shared as G assert G - unicode = str + str = str from .exc_fmt import str_e python2 = False except ImportError: python2 = True - from exc_fmt import str_e - import shared as G + from .exc_fmt import str_e + from . import shared as G LOG_LEVELS = { @@ -47,7 +47,7 @@ def safe_print(msg): try: print(msg) except UnicodeEncodeError: - print(msg.encode('utf-8')) + print((msg.encode('utf-8'))) # Overridden by each editor @@ -83,7 +83,7 @@ def display(self): if self.level < LOG_LEVEL: return - msg = unicode(self) + msg = str(self) if G.LOG_TO_CONSOLE or G.CHAT_VIEW is None: floobits_log(msg) safe_print(msg) @@ -104,20 +104,20 @@ def __unicode__(self): level = LOG_LEVELS_REVERSE.get(self.level, 'UNKNOWN').rjust(5) try: - return unicode(msg).format(level=level, user=self.username, time=time.ctime(self.timestamp), msg=self.msg) + return str(msg).format(level=level, user=self.username, time=time.ctime(self.timestamp), msg=self.msg) except UnicodeEncodeError: - return unicode(msg).format(level=level, user=self.username, time=time.ctime(self.timestamp), msg=self.msg.encode( + return str(msg).format(level=level, user=self.username, time=time.ctime(self.timestamp), msg=self.msg.encode( 'utf-8')) def msg_format(message, *args, **kwargs): try: - message = unicode(message) + message = str(message) except UnicodeEncodeError: message = str(message) for arg in args: try: - message += unicode(arg) + message += str(arg) except UnicodeEncodeError: message += arg if kwargs: diff --git a/rplugin/python/floobits/common/protocols/__init__.py b/rplugin/python3/floobits/common/protocols/__init__.py similarity index 100% rename from rplugin/python/floobits/common/protocols/__init__.py rename to rplugin/python3/floobits/common/protocols/__init__.py diff --git a/rplugin/python/floobits/common/protocols/base.py b/rplugin/python3/floobits/common/protocols/base.py similarity index 100% rename from rplugin/python/floobits/common/protocols/base.py rename to rplugin/python3/floobits/common/protocols/base.py diff --git a/rplugin/python/floobits/common/protocols/floo_proto.py b/rplugin/python3/floobits/common/protocols/floo_proto.py similarity index 99% rename from rplugin/python/floobits/common/protocols/floo_proto.py rename to rplugin/python3/floobits/common/protocols/floo_proto.py index 53662e1..1f42d2b 100644 --- a/rplugin/python/floobits/common/protocols/floo_proto.py +++ b/rplugin/python3/floobits/common/protocols/floo_proto.py @@ -22,8 +22,8 @@ from floo import editor from floo.common import api, cert, msg, shared as G, utils from floo.common.exc_fmt import str_e - import base - import proxy + from . import base + from . import proxy try: connect_errno = (errno.WSAEWOULDBLOCK, errno.WSAEALREADY, errno.WSAEINVAL) diff --git a/rplugin/python/floobits/common/protocols/no_reconnect.py b/rplugin/python3/floobits/common/protocols/no_reconnect.py similarity index 97% rename from rplugin/python/floobits/common/protocols/no_reconnect.py rename to rplugin/python3/floobits/common/protocols/no_reconnect.py index 40d41f4..86f8159 100644 --- a/rplugin/python/floobits/common/protocols/no_reconnect.py +++ b/rplugin/python3/floobits/common/protocols/no_reconnect.py @@ -20,7 +20,7 @@ def reconnect(self): try: api.get_workspace(self.host, 'Floobits', 'doesnotexist') except Exception as e: - print(str_e(e)) + print((str_e(e))) editor.error_message('Something went wrong. See https://%s/help/floorc to complete the installation.' % self.host) else: if G.OUTBOUND_FILTERING: diff --git a/rplugin/python/floobits/common/protocols/proxy.py b/rplugin/python3/floobits/common/protocols/proxy.py similarity index 100% rename from rplugin/python/floobits/common/protocols/proxy.py rename to rplugin/python3/floobits/common/protocols/proxy.py diff --git a/rplugin/python/floobits/common/protocols/tcp_server.py b/rplugin/python3/floobits/common/protocols/tcp_server.py similarity index 97% rename from rplugin/python/floobits/common/protocols/tcp_server.py rename to rplugin/python3/floobits/common/protocols/tcp_server.py index a650924..433e3d5 100644 --- a/rplugin/python/floobits/common/protocols/tcp_server.py +++ b/rplugin/python3/floobits/common/protocols/tcp_server.py @@ -4,7 +4,7 @@ from . import base from ..protocols import floo_proto except (ImportError, ValueError): - import base + from . import base from floo.common.protocols import floo_proto diff --git a/rplugin/python/floobits/common/proxy.py b/rplugin/python3/floobits/common/proxy.py similarity index 91% rename from rplugin/python/floobits/common/proxy.py rename to rplugin/python3/floobits/common/proxy.py index 75eef5a..347c719 100644 --- a/rplugin/python/floobits/common/proxy.py +++ b/rplugin/python3/floobits/common/proxy.py @@ -6,11 +6,11 @@ from .handlers import base from .protocols import floo_proto except (ImportError, ValueError): - import msg - import shared as G - import reactor - from handlers import base - from protocols import floo_proto + from . import msg + from . import shared as G + from . import reactor + from .handlers import base + from .protocols import floo_proto # KANS: this should use base, but I want the connection logic from FlooProto (ie, move that shit to base) @@ -75,7 +75,7 @@ def main(): _, port = reactor.reactor.listen(proxy) def on_ready(): - print('Now listening on %s' % port) + print(('Now listening on %s' % port)) utils.set_timeout(on_ready, 100) reactor.reactor.block() diff --git a/rplugin/python/floobits/common/reactor.py b/rplugin/python3/floobits/common/reactor.py similarity index 100% rename from rplugin/python/floobits/common/reactor.py rename to rplugin/python3/floobits/common/reactor.py diff --git a/rplugin/python/floobits/common/repo.py b/rplugin/python3/floobits/common/repo.py similarity index 92% rename from rplugin/python/floobits/common/repo.py rename to rplugin/python3/floobits/common/repo.py index 56b8e06..07a0262 100644 --- a/rplugin/python/floobits/common/repo.py +++ b/rplugin/python3/floobits/common/repo.py @@ -9,10 +9,10 @@ from .exc_fmt import str_e assert api and G and msg and str_e except ImportError: - import api - import msg - import shared as G - from exc_fmt import str_e + from . import api + from . import msg + from . import shared as G + from .exc_fmt import str_e REPO_MAPPING = { @@ -32,7 +32,7 @@ def detect_type(d): - for repo_type, v in REPO_MAPPING.items(): + for repo_type, v in list(REPO_MAPPING.items()): repo_path = os.path.join(d, v['dir']) try: s = os.stat(repo_path) diff --git a/rplugin/python/floobits/common/shared.py b/rplugin/python3/floobits/common/shared.py similarity index 100% rename from rplugin/python/floobits/common/shared.py rename to rplugin/python3/floobits/common/shared.py diff --git a/rplugin/python/floobits/common/utils.py b/rplugin/python3/floobits/common/utils.py similarity index 96% rename from rplugin/python/floobits/common/utils.py rename to rplugin/python3/floobits/common/utils.py index e54c263..6b5cc7c 100644 --- a/rplugin/python/floobits/common/utils.py +++ b/rplugin/python3/floobits/common/utils.py @@ -12,7 +12,7 @@ from urllib.parse import urlparse assert urlparse except ImportError: - from urlparse import urlparse + from urllib.parse import urlparse try: from .. import editor @@ -23,10 +23,10 @@ assert G and DMP except ImportError: import editor - import msg - from exc_fmt import str_e - import shared as G - from lib import DMP + from . import msg + from .exc_fmt import str_e + from . import shared as G + from .lib import DMP class JOIN_ACTION(object): @@ -83,7 +83,7 @@ def to_json(self): def reload_settings(): floorc_settings = load_floorc_json() - for name, val in floorc_settings.items(): + for name, val in list(floorc_settings.items()): setattr(G, name, val) validate_auth(G.AUTH) if G.SHARE_DIR: @@ -118,14 +118,14 @@ def load_floorc_json(): except ValueError: return s - for k, v in default_settings.items(): + for k, v in list(default_settings.items()): s[k.upper()] = v return s def save_floorc_json(s): floorc_json = {} - for k, v in s.items(): + for k, v in list(s.items()): floorc_json[k.lower()] = v msg.log('Writing ', floorc_json) with open(G.FLOORC_JSON_PATH, 'w') as fd: @@ -137,7 +137,7 @@ def validate_auth(auth): msg.error('floorc.json validation error: Auth section is not an object!') return False to_delete = [] - for k, v in auth.items(): + for k, v in list(auth.items()): if type(v) != dict: msg.error('floorc.json validation error: host "', k, '" has invalid auth credentials. Did you put a setting in the auth section?') to_delete.append(k) @@ -183,7 +183,7 @@ def _set_timeout(func, timeout, repeat, *args, **kwargs): try: from . import api except ImportError: - import api + from . import api @api.send_errors def timeout_func(): @@ -401,8 +401,8 @@ def normalize_persistent_data(): for rw in persistent_data['recent_workspaces']: rw['url'] = normalize_url(rw['url']) - for owner, workspaces in persistent_data['workspaces'].items(): - for name, workspace in workspaces.items(): + for owner, workspaces in list(persistent_data['workspaces'].items()): + for name, workspace in list(workspaces.items()): workspace['url'] = normalize_url(workspace['url']) workspace['path'] = unfuck_path(workspace['path']) update_persistent_data(persistent_data) @@ -435,8 +435,8 @@ def update_recent_workspaces(workspace_url): def get_workspace_by_path(path, _filter): path = unfuck_path(path) - for owner, workspaces in get_persistent_data()['workspaces'].items(): - for name, workspace in workspaces.items(): + for owner, workspaces in list(get_persistent_data()['workspaces'].items()): + for name, workspace in list(workspaces.items()): if unfuck_path(workspace['path']) == path: r = _filter(workspace['url']) if r: diff --git a/rplugin/python/floobits/editor.py b/rplugin/python3/floobits/editor.py similarity index 98% rename from rplugin/python/floobits/editor.py rename to rplugin/python3/floobits/editor.py index f27af6d..d9c811f 100644 --- a/rplugin/python/floobits/editor.py +++ b/rplugin/python3/floobits/editor.py @@ -66,7 +66,7 @@ def call_timeouts(): calling_timeouts = True now = time.time() to_remove = [] - for t, tos in timeouts.items(): + for t, tos in list(timeouts.items()): if now >= t: for timeout in tos: timeout() diff --git a/rplugin/python/floobits/view.py b/rplugin/python3/floobits/view.py similarity index 98% rename from rplugin/python/floobits/view.py rename to rplugin/python3/floobits/view.py index 04d3602..4b532a7 100644 --- a/rplugin/python/floobits/view.py +++ b/rplugin/python3/floobits/view.py @@ -1,6 +1,6 @@ -import editor +from . import editor -from common import msg, utils, shared as G +from .common import msg, utils, shared as G from collections import defaultdict vim = None @@ -159,7 +159,7 @@ def clear_highlight(self, user_id): del self.current_highlights[user_id] def clear_all_highlights(self): - for user_id in self.current_highlights.keys(): + for user_id in list(self.current_highlights.keys()): self.clear_highlight(user_id) def highlight(self, ranges, user_id): diff --git a/rplugin/python/floobits/vim_handler.py b/rplugin/python3/floobits/vim_handler.py similarity index 98% rename from rplugin/python/floobits/vim_handler.py rename to rplugin/python3/floobits/vim_handler.py index 35b86c8..5e36fa0 100644 --- a/rplugin/python/floobits/vim_handler.py +++ b/rplugin/python3/floobits/vim_handler.py @@ -11,9 +11,9 @@ ssl = False try: - unicode() + str() except NameError: - unicode = str + str = str vim = None @@ -24,10 +24,10 @@ from .common.handlers import floo_handler assert G and msg and utils except ImportError: - import editor - from common import msg, shared as G, utils - from common.handlers import floo_handler - from view import View, vim_buf_to_text + from . import editor + from .common import msg, shared as G, utils + from .common.handlers import floo_handler + from .view import View, vim_buf_to_text def get_buf(view): @@ -265,7 +265,7 @@ def prompt_join_hangout(self, hangout_url): return hangout_client = None users = self.workspace_info.get('users') - for user_id, user in users.items(): + for user_id, user in list(users.items()): if user['username'] == G.USERNAME and 'hangout' in user['client']: hangout_client = user break @@ -366,7 +366,7 @@ def _on_delete_buf(self, data): G.WORKSPACE_WINDOW.focus_view(view) G.WORKSPACE_WINDOW.run_command("close_file") except Exception as e: - msg.debug('Error closing view: %s' % unicode(e)) + msg.debug('Error closing view: %s' % str(e)) try: buf = self.bufs.get(buf_id) if buf: diff --git a/rplugin/python/floobits/vui.py b/rplugin/python3/floobits/vui.py similarity index 95% rename from rplugin/python/floobits/vui.py rename to rplugin/python3/floobits/vui.py index 90b5e1d..1a6f400 100644 --- a/rplugin/python/floobits/vui.py +++ b/rplugin/python3/floobits/vui.py @@ -3,9 +3,9 @@ from . import msg, reactor, shared as G, flooui from ..common import vim_handler, editor except (ImportError, ValueError): - from common import msg, reactor, shared as G, flooui - import vim_handler - import editor + from .common import msg, reactor, shared as G, flooui + from . import vim_handler + from . import editor reactor = reactor.reactor @@ -91,7 +91,7 @@ def users_in_workspace(self): if not G.AGENT: return msg.warn('Not connected to a workspace.') vim.command('echom "Users connected to %s"' % (G.AGENT.workspace,)) - for user in G.AGENT.workspace_info['users'].values(): + for user in list(G.AGENT.workspace_info['users'].values()): vim.command('echom " %s connected with %s on %s"' % (user['username'], user['client'], user['platform'])) def list_messages(self):