# coding=utf-8
import sublime
import sublime_plugin
import os
import sys
import subprocess
import zipfile
import urllib
import urllib2
import json
from fnmatch import fnmatch
import re
import threading
import datetime
import time
import shutil
import tempfile
import httplib
import socket
import hashlib
import base64
import locale
import urlparse
import gzip
import StringIO
import zlib
if os.name == 'nt':
from ctypes import windll, create_unicode_buffer
def add_to_path(path):
# Python 2.x on Windows can't properly import from non-ASCII paths, so
# this code added the DOC 8.3 version of the lib folder to the path in
# case the user's username includes non-ASCII characters
if os.name == 'nt':
buf = create_unicode_buffer(512)
if windll.kernel32.GetShortPathNameW(path, buf, len(buf)):
path = buf.value
if path not in sys.path:
sys.path.append(path)
lib_folder = os.path.join(sublime.packages_path(), 'Package Control', 'lib')
add_to_path(os.path.join(lib_folder, 'all'))
import semver
if os.name == 'nt':
add_to_path(os.path.join(lib_folder, 'windows'))
from ntlm import ntlm
def unicode_from_os(e):
# This is needed as some exceptions coming from the OS are
# already encoded and so just calling unicode(e) will result
# in an UnicodeDecodeError as the string isn't in ascii form.
try:
# Sublime Text on OS X does not seem to report the correct encoding
# so we hard-code that to UTF-8
encoding = 'UTF-8' if os.name == 'darwin' else locale.getpreferredencoding()
return unicode(str(e), encoding)
# If the "correct" encoding did not work, try some defaults, and then just
# obliterate characters that we can't seen to decode properly
except UnicodeDecodeError:
encodings = ['utf-8', 'cp1252']
for encoding in encodings:
try:
return unicode(str(e), encoding, errors='strict')
except:
pass
return unicode(str(e), errors='replace')
def create_cmd(args, basename_binary=False):
if basename_binary:
args[0] = os.path.basename(args[0])
if os.name == 'nt':
return subprocess.list2cmdline(args)
else:
escaped_args = []
for arg in args:
if re.search('^[a-zA-Z0-9/_^\\-\\.:=]+$', arg) == None:
arg = u"'" + arg.replace(u"'", u"'\\''") + u"'"
escaped_args.append(arg)
return u' '.join(escaped_args)
# Monkey patch AbstractBasicAuthHandler to prevent infinite recursion
def non_recursive_http_error_auth_reqed(self, authreq, host, req, headers):
authreq = headers.get(authreq, None)
if not hasattr(self, 'retried'):
self.retried = 0
if self.retried > 5:
raise urllib2.HTTPError(req.get_full_url(), 401, "basic auth failed",
headers, None)
else:
self.retried += 1
if authreq:
mo = urllib2.AbstractBasicAuthHandler.rx.search(authreq)
if mo:
scheme, quote, realm = mo.groups()
if scheme.lower() == 'basic':
return self.retry_http_basic_auth(host, req, realm)
urllib2.AbstractBasicAuthHandler.http_error_auth_reqed = non_recursive_http_error_auth_reqed
class DebuggableHTTPResponse(httplib.HTTPResponse):
"""
A custom HTTPResponse that formats debugging info for Sublime Text
"""
_debug_protocol = 'HTTP'
def __init__(self, sock, debuglevel=0, strict=0, method=None):
# We have to use a positive debuglevel to get it passed to here,
# however we don't want to use it because by default debugging prints
# to the stdout and we can't capture it, so we use a special -1 value
if debuglevel == 5:
debuglevel = -1
httplib.HTTPResponse.__init__(self, sock, debuglevel, strict, method)
def begin(self):
return_value = httplib.HTTPResponse.begin(self)
if self.debuglevel == -1:
print '%s: Urllib2 %s Debug Read' % (__name__, self._debug_protocol)
headers = self.msg.headers
versions = {
9: 'HTTP/0.9',
10: 'HTTP/1.0',
11: 'HTTP/1.1'
}
status_line = versions[self.version] + ' ' + str(self.status) + ' ' + self.reason
headers.insert(0, status_line)
for line in headers:
print u" %s" % line.rstrip()
return return_value
def read(self, *args):
try:
return httplib.HTTPResponse.read(self, *args)
except (httplib.IncompleteRead) as (e):
return e.partial
class DebuggableHTTPSResponse(DebuggableHTTPResponse):
"""
A version of DebuggableHTTPResponse that sets the debug protocol to HTTPS
"""
_debug_protocol = 'HTTPS'
class DebuggableHTTPConnection(httplib.HTTPConnection):
"""
A custom HTTPConnection that formats debugging info for Sublime Text
"""
response_class = DebuggableHTTPResponse
_debug_protocol = 'HTTP'
def __init__(self, host, port=None, strict=None,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT, **kwargs):
self.passwd = kwargs.get('passwd')
# Python 2.6.1 on OS X 10.6 does not include these
self._tunnel_host = None
self._tunnel_port = None
self._tunnel_headers = {}
httplib.HTTPConnection.__init__(self, host, port, strict, timeout)
def connect(self):
if self.debuglevel == -1:
print '%s: Urllib2 %s Debug General' % (__name__, self._debug_protocol)
print u" Connecting to %s on port %s" % (self.host, self.port)
httplib.HTTPConnection.connect(self)
def send(self, string):
# We have to use a positive debuglevel to get it passed to the
# HTTPResponse object, however we don't want to use it because by
# default debugging prints to the stdout and we can't capture it, so
# we temporarily set it to -1 for the standard httplib code
reset_debug = False
if self.debuglevel == 5:
reset_debug = 5
self.debuglevel = -1
httplib.HTTPConnection.send(self, string)
if reset_debug or self.debuglevel == -1:
if len(string.strip()) > 0:
print '%s: Urllib2 %s Debug Write' % (__name__, self._debug_protocol)
for line in string.strip().splitlines():
print ' ' + line
if reset_debug:
self.debuglevel = reset_debug
def request(self, method, url, body=None, headers={}):
original_headers = headers.copy()
# Handles the challenge request response cycle before the real request
proxy_auth = headers.get('Proxy-Authorization')
if os.name == 'nt' and proxy_auth and proxy_auth.lstrip()[0:4] == 'NTLM':
# The default urllib2.AbstractHTTPHandler automatically sets the
# Connection header to close because of urllib.addinfourl(), but in
# this case we are going to do some back and forth first for the NTLM
# proxy auth
headers['Connection'] = 'Keep-Alive'
self._send_request(method, url, body, headers)
response = self.getresponse()
content_length = int(response.getheader('content-length', 0))
if content_length:
response._safe_read(content_length)
proxy_authenticate = response.getheader('proxy-authenticate', None)
if not proxy_authenticate:
raise URLError('Invalid NTLM proxy authentication response')
ntlm_challenge = re.sub('^\s*NTLM\s+', '', proxy_authenticate)
if self.host.find(':') != -1:
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Sublime Text 2.0.1 x64 汉化绿色解决中文乱码版 Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。 Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。[1]Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。
资源推荐
资源详情
资源评论
收起资源包目录
Sublime Text 2.0.1 x64 汉化绿色解决乱码 (2000个子文件)
116 797B
116 797B
1c5282418e2cb4989cd6beddcdbab0b5 6KB
1c5282418e2cb4989cd6beddcdbab0b5 6KB
7f4f8622b4fd001c7f648e09aae7edaa 9KB
7f4f8622b4fd001c7f648e09aae7edaa 9KB
897abe0b41fd2f64e9e2e351cbc36d76 15KB
897abe0b41fd2f64e9e2e351cbc36d76 15KB
en_GB.aff 27KB
en_GB.aff 27KB
en_US.aff 3KB
en_US.aff 3KB
update_keymaps.bat 143B
update_keymaps.bat 143B
Startup.cache 167KB
Startup.cache 167KB
Matlab.tmLanguage.cache 25KB
Matlab.tmLanguage.cache 25KB
Meta Info Summary.cache 23KB
Meta Info Summary.cache 23KB
PHP.tmLanguage.cache 20KB
PHP.tmLanguage.cache 20KB
Objective-C.tmLanguage.cache 18KB
Objective-C.tmLanguage.cache 18KB
Completions HTML Attributes.tmPreferences.cache 12KB
Completions HTML Attributes.tmPreferences.cache 12KB
D.tmLanguage.cache 8KB
D.tmLanguage.cache 8KB
AppleScript.tmLanguage.cache 7KB
AppleScript.tmLanguage.cache 7KB
Clojure.tmLanguage.cache 7KB
Clojure.tmLanguage.cache 7KB
ActionScript.tmLanguage.cache 7KB
ActionScript.tmLanguage.cache 7KB
Ruby.tmLanguage.cache 7KB
Ruby.tmLanguage.cache 7KB
Python.tmLanguage.cache 6KB
Python.tmLanguage.cache 6KB
JavaScript.tmLanguage.cache 5KB
JavaScript.tmLanguage.cache 5KB
CSS.tmLanguage.cache 5KB
CSS.tmLanguage.cache 5KB
C.tmLanguage.cache 5KB
C.tmLanguage.cache 5KB
Solarized (Dark).tmTheme.cache 5KB
Solarized (Dark).tmTheme.cache 5KB
Solarized (Light).tmTheme.cache 5KB
Solarized (Light).tmTheme.cache 5KB
OCaml.tmLanguage.cache 5KB
OCaml.tmLanguage.cache 5KB
Perl.tmLanguage.cache 5KB
Perl.tmLanguage.cache 5KB
Erlang.tmLanguage.cache 4KB
Erlang.tmLanguage.cache 4KB
LaTeX.tmLanguage.cache 4KB
LaTeX.tmLanguage.cache 4KB
Groovy.tmLanguage.cache 4KB
Groovy.tmLanguage.cache 4KB
Shell-Unix-Generic.tmLanguage.cache 3KB
Shell-Unix-Generic.tmLanguage.cache 3KB
Markdown.tmLanguage.cache 3KB
Markdown.tmLanguage.cache 3KB
Markdown.tmLanguage.cache 3KB
Markdown.tmLanguage.cache 3KB
Haskell.tmLanguage.cache 3KB
Haskell.tmLanguage.cache 3KB
Syntax Summary.cache 3KB
Syntax Summary.cache 3KB
Go.tmLanguage.cache 3KB
Go.tmLanguage.cache 3KB
Cfscript.tmLanguage.cache 3KB
Cfscript.tmLanguage.cache 3KB
Java.tmLanguage.cache 3KB
Java.tmLanguage.cache 3KB
HTML 5.tmLanguage.cache 3KB
HTML 5.tmLanguage.cache 3KB
HTML.tmLanguage.cache 2KB
HTML.tmLanguage.cache 2KB
SQL.tmLanguage.cache 2KB
SQL.tmLanguage.cache 2KB
jQueryJavaScript.tmLanguage.cache 2KB
jQueryJavaScript.tmLanguage.cache 2KB
ASP.tmLanguage.cache 2KB
ASP.tmLanguage.cache 2KB
TeX Math.tmLanguage.cache 2KB
TeX Math.tmLanguage.cache 2KB
Scala.tmLanguage.cache 2KB
Scala.tmLanguage.cache 2KB
Sunburst.tmTheme.cache 2KB
Sunburst.tmTheme.cache 2KB
Pastels on Dark.tmTheme.cache 2KB
Pastels on Dark.tmTheme.cache 2KB
Tcl.tmLanguage.cache 2KB
Tcl.tmLanguage.cache 2KB
C++.tmLanguage.cache 2KB
C++.tmLanguage.cache 2KB
C#.tmLanguage.cache 2KB
C#.tmLanguage.cache 2KB
Ruby on Rails.tmLanguage.cache 2KB
Ruby on Rails.tmLanguage.cache 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- sisess2014-12-26顶,太好用了,神器
雁子
- 粉丝: 34
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功