Skip to content

Commit ff961c0

Browse files
committed
Base support for python 3
1 parent cebc566 commit ff961c0

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

SublimeCodeIntel.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
}
6868
}
6969
"""
70+
from __future__ import print_function
7071

7172
VERSION = "2.0.2"
7273

@@ -81,8 +82,10 @@
8182
import sublime_plugin
8283
import threading
8384
import logging
84-
85-
from cStringIO import StringIO
85+
try:
86+
from cStringIO import StringIO
87+
except ImportError:
88+
from io import StringIO
8689

8790
CODEINTEL_HOME_DIR = os.path.expanduser(os.path.join('~', '.codeintel'))
8891
__file__ = os.path.normpath(os.path.abspath(__file__))
@@ -194,7 +197,7 @@ def _calltip_set():
194197
current_type, current_msg, current_order = status_msg.get(lid, [None, None, 0])
195198
if msg != current_msg and order == current_order:
196199
if msg:
197-
print >>condeintel_log_file, "+", "%s: %s" % (ltype.capitalize(), msg)
200+
print("+", "%s: %s" % (ltype.capitalize(), msg), file=condeintel_log_file)
198201
(logger or log.info)(msg)
199202
if ltype != 'debug':
200203
if msg:
@@ -525,7 +528,7 @@ def codeintel_manager(folders_id):
525528
condeintel_log_file = open(condeintel_log_filename, 'w', 1)
526529
codeintel_log.handlers = [logging.StreamHandler(condeintel_log_file)]
527530
msg = "Starting logging SublimeCodeIntel v%s rev %s (%s) on %s" % (VERSION, get_revision()[:12], os.stat(__file__)[stat.ST_MTIME], datetime.datetime.now().ctime())
528-
print >>condeintel_log_file, "%s\n%s" % (msg, "=" * len(msg))
531+
print("%s\n%s" % (msg, "=" * len(msg)), file=condeintel_log_file)
529532

530533
_ci_mgr_[folders_id] = mgr
531534
return mgr
@@ -638,13 +641,13 @@ def _codeintel_scan():
638641
_config = {}
639642
try:
640643
tryReadDict(config_default_file, _config)
641-
except Exception, e:
644+
except Exception as e:
642645
msg = "Malformed configuration file '%s': %s" % (config_default_file, e)
643646
log.error(msg)
644647
codeintel_log.error(msg)
645648
try:
646649
tryReadDict(config_file, _config)
647-
except Exception, e:
650+
except Exception as e:
648651
msg = "Malformed configuration file '%s': %s" % (config_default_file, e)
649652
log.error(msg)
650653
codeintel_log.error(msg)
@@ -703,7 +706,7 @@ def _codeintel_scan():
703706
despair = 0
704707
despaired = False
705708
msg = "Updating indexes for '%s'... The first time this can take a while." % lang
706-
print >>condeintel_log_file, msg
709+
print(msg, file=condeintel_log_file)
707710
logger(view, 'info', msg, timeout=20000, delay=1000)
708711
if not path or is_scratch:
709712
buf.scan() # FIXME: Always scanning unsaved files (since many tabs can have unsaved files, or find other path as ID)
@@ -717,7 +720,7 @@ def _codeintel_scan():
717720
buf = None
718721
if callback:
719722
msg = "Doing CodeIntel for '%s' (hold on)..." % lang
720-
print >>condeintel_log_file, msg
723+
print(msg, file=condeintel_log_file)
721724
logger(view, 'info', msg, timeout=20000, delay=1000)
722725
callback(buf, msgs)
723726
else:
@@ -803,7 +806,7 @@ def _codeintel(buf, msgs):
803806
timestr = "%sms" % int(round(total))
804807
if not despaired or total < timeout:
805808
msg = "Done '%s' CodeIntel! Full CodeIntel took %s" % (lang, timestr)
806-
print >>condeintel_log_file, msg
809+
print(msg, file=condeintel_log_file)
807810

808811
def _callback():
809812
view_sel = view.sel()
@@ -813,7 +816,7 @@ def _callback():
813816
sublime.set_timeout(_callback, 0)
814817
else:
815818
msg = "Just finished indexing '%s'! Please try again. Full CodeIntel took %s" % (lang, timestr)
816-
print >>condeintel_log_file, msg
819+
print(msg, file=condeintel_log_file)
817820
logger(view, 'info', msg, timeout=3000)
818821
codeintel_scan(view, path, content, lang, _codeintel, pos, forms)
819822

0 commit comments

Comments
 (0)