Skip to content
Browse files

Better detection of ST2 and ST3

  • Loading branch information...
1 parent d388faa commit 5428865c0c40030aa2d9b7ca551d89dcb060ae64 @msiniscalchi msiniscalchi committed
View
8 delete_temp_files.py
@@ -1,14 +1,16 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
+ _ST3 = False
# we are on ST2 and Python 2.X
import getTeXRoot
else:
+ _ST3 = True
from . import getTeXRoot
-import sublime, sublime_plugin
+import sublime_plugin
import os
class Delete_temp_filesCommand(sublime_plugin.WindowCommand):
View
8 getTeXRoot.py
@@ -1,11 +1,11 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
- pass
+ _ST3 = False
else:
- pass
+ _ST3 = True
import os.path, re
View
8 jumpToPDF.py
@@ -1,14 +1,16 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
+ _ST3 = False
import getTeXRoot
else:
+ _ST3 = True
from . import getTeXRoot
-import sublime, sublime_plugin, os.path, subprocess, time
+import sublime_plugin, os.path, subprocess, time
# Jump to current line in PDF file
# NOTE: must be called with {"from_keybinding": <boolean>} as arg
View
10 latexCommand.py
@@ -1,13 +1,13 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
- pass
+ _ST3 = True
else:
- pass
+ _ST3 = False
-import sublime, sublime_plugin
+import sublime_plugin
import re
View
10 latexEnvCloser.py
@@ -1,14 +1,14 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
- pass
+ _ST3 = False
else:
- pass
+ _ST3 = True
-import sublime, sublime_plugin
+import sublime_plugin
# Insert environment closer
# this only looks at the LAST \begin{...}
View
8 latex_cite_completions.py
@@ -1,14 +1,16 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
+ _ST3 = False
import getTeXRoot
else:
+ _ST3 = True
from . import getTeXRoot
-import sublime, sublime_plugin
+import sublime_plugin
import os, os.path
import re
import codecs
View
7 latex_ref_cite_completions.py
@@ -1,12 +1,15 @@
# ST2/ST3 compat
from __future__ import print_function
import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
+ _ST3 = False
import getTeXRoot
from latex_cite_completions import OLD_STYLE_CITE_REGEX, NEW_STYLE_CITE_REGEX
from latex_ref_completions import OLD_STYLE_REF_REGEX, NEW_STYLE_REF_REGEX
else:
+ _ST3 = True
from . import getTeXRoot
from .latex_cite_completions import OLD_STYLE_CITE_REGEX, NEW_STYLE_CITE_REGEX
from .latex_ref_completions import OLD_STYLE_REF_REGEX, NEW_STYLE_REF_REGEX
@@ -17,7 +20,7 @@
# First stab: ideally we should do all matching here, then dispatch via Python, without
# invoking commands
-import sublime, sublime_plugin
+import sublime_plugin
import re
View
8 latex_ref_completions.py
@@ -1,13 +1,15 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
+ _ST3 = False
import getTeXRoot
else:
+ _ST3 = True
from . import getTeXRoot
-import sublime, sublime_plugin
+import sublime_plugin
import os, os.path
import re
View
10 makePDF.py
@@ -1,11 +1,13 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
+ _ST3 = False
import getTeXRoot
import parseTeXlog
else:
+ _ST3 = True
from . import getTeXRoot
from . import parseTeXlog
@@ -61,7 +63,7 @@ def run ( self ):
# The user decides in the build system whether he wants to append $PATH
# or tuck it at the front: "$PATH;C:\\new\\path", "C:\\new\\path;$PATH"
# Handle differently in Python 2 and 3, to be safe:
- if sys.version_info[0] == 2:
+ if not _ST3:
os.environ["PATH"] = os.path.expandvars(self.caller.path).encode(sys.getfilesystemencoding())
else:
os.environ["PATH"] = os.path.expandvars(self.caller.path)
@@ -288,7 +290,7 @@ def do_output(self, data):
# decoding in thread, so we can pass coded and decoded data
# handle both lists and strings
# Need different handling for python 2 and 3
- if sys.version_info[0] == 2:
+ if not _ST3:
strdata = data if isinstance(data, types.StringTypes) else "\n".join(data)
else:
strdata = data if isinstance(data, str) else "\n".join(data)
View
10 parseTeXlog.py
@@ -1,11 +1,11 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
- pass
+ _ST3 = False
else:
- pass
+ _ST3 = True
import re
@@ -15,7 +15,7 @@
# To accommodate both Python 2 and 3
def advance_iterator(it):
- if sys.version_info[0] == 2:
+ if not _ST3:
return it.next()
else:
return next(it)
View
10 texSections.py
@@ -1,14 +1,14 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
- pass
+ _ST3 = False
else:
- pass
+ _ST3 = True
-import sublime, sublime_plugin, os, os.path, re
+import sublime_plugin, os, os.path, re
# References and citations
View
10 toggle_auto.py
@@ -1,14 +1,14 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
- pass
+ _ST3 = False
else:
- pass
+ _ST3 = True
-import sublime, sublime_plugin
+import sublime_plugin
# Toggle focus after jumping to PDF
View
10 toggle_focus.py
@@ -1,14 +1,14 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
- pass
+ _ST3 = False
else:
- pass
+ _ST3 = True
-import sublime, sublime_plugin
+import sublime_plugin
# Toggle focus after jumping to PDF
View
8 toggle_fwdsync.py
@@ -1,11 +1,11 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
- pass
+ _ST3 = False
else:
- pass
+ _ST3 = True
import sublime, sublime_plugin
View
8 viewPDF.py
@@ -1,13 +1,15 @@
# ST2/ST3 compat
from __future__ import print_function
-import sys
-if sys.version_info[0] == 2:
+import sublime
+if sublime.version() < '3000':
# we are on ST2 and Python 2.X
+ _ST3 = False
import getTeXRoot
else:
+ _ST3 = True
from . import getTeXRoot
-import sublime, sublime_plugin, os, os.path, platform
+import sublime_plugin, os, os.path, platform
from subprocess import Popen

0 comments on commit 5428865

Please sign in to comment.
Something went wrong with that request. Please try again.