def run(self, edit, encoding, file_name, need_codecs):
self.view.set_name('ConvertToUTF8 Instructions')
self.view.set_scratch(True)
self.view.settings().set("word_wrap", True)
msg = 'File: {0}\nEncoding: {1}\nError: '.format(file_name, encoding)
if need_codecs:
msg = msg + 'Codecs missing\n\n'
branch = self.get_branch(sublime.platform(), sublime.arch())
if branch:
ver = '33' if ST3 else '26'
msg = msg + 'Please install Codecs{0} plugin (https://github.com/seanliang/Codecs{0}/tree/{1}).\n'.format(ver, branch)
else:
import platform
msg = msg + 'Please send the following information to sunlxy (at) yahoo.com:\n====== Debug Information ======\nVersion: {0}-{1}\nPlatform: {2}\nPath: {3}\nEncoding: {4}\n'.format(
sublime.version(), sublime.arch(), platform.platform(), sys.path, encoding
)
else:
msg = msg + 'Unsupported encoding, see http://docs.python.org/library/codecs.html#standard-encodings\n\nPlease try other tools such as iconv.\n'
self.view.insert(edit, 0, msg)
self.view.set_read_only(True)
self.view.window().focus_view(self.view)
python类arch()的实例源码
def get_branch(self, platform, arch):
return [{
'linux-x64': 'master',
'linux-x32': 'x32',
}, {
'linux-x64': 'linux-x64',
'linux-x32': 'linux-x32',
'osx-x64': 'osx',
}][ST3].get(platform + '-' + arch)
def setLocale(locale, force = False):
if not locale:
return
if (not force) and locale == getSetting('locale'):
return
link = getLink(locale)
if link:
locale = link
m = {}
d = os.path.join(mDir, v, locale)
m.update(findMenu(d))
sDir = ''
d = os.path.join(mDir, version)
ld = os.path.join(d, locale)
if (not os.path.isdir(ld)) and getSetting('findSimilarVer', True):
sDir = findSimilarVer()
if not sDir:
return
d = os.path.join(mDir, sDir)
d = os.path.join(d, locale)
if not os.path.isdir(d):
return
m.update(findMenu(d))
d = os.path.join(d, p)
m.update(findMenu(d))
d = os.path.join(d, sublime.arch())
m.update(findMenu(d))
updateMenu(m)
if getSetting('updateTopMenu', True):
updateTopMenu()
sublime.status_message('Locale ' + locale + ' has loaded.')
def has_libclang():
"""Ensure libclang tests will run only on platforms that support this.
Returns:
str: row contents
"""
# Older version of Sublime Text x64 have ctypes crash bug.
if platform.system() == "Windows" and sublime.arch() == "x64" and \
int(sublime.version()) < 3123:
return False
return True
def collect(self):
self.elements.clear()
db0 = DataBlock('Version and architecture')
db0.items.append(DataItem('name', 'Sublime Text'))
db0.items.append(DataItem('version', sublime.version()))
db0.items.append(DataItem('architecture', sublime.arch()))
db0.items.append(DataItem('channel', sublime.channel()))
db0.items.append(DataItem('platform', sublime.platform()))
view = sublime.active_window().active_view()
view_settings = view.settings()
db1 = DataBlock('View settings')
for setting_name in ('syntax', 'tab_size', 'translate_tabs_to_spaces'):
db1.items.append(DataItem(setting_name, view_settings.get(setting_name)))
db2 = DataBlock('View state')
db2.items.append(DataItem('is view dirty', view.is_dirty()))
db2.items.append(DataItem('is view readonly', view.is_read_only()))
db1.items.append(DataItem('encoding', view.encoding()))
db1.items.append(DataItem('em width', view.em_width()))
db1.items.append(DataItem('selection count', len(view.sel())))
db1.items.append(DataItem('has non empty selections', view.has_non_empty_selection_region()))
self.elements.append(db0)
# TODO: Split the rest up into methods.
self.collect_package_data()
self.elements.append(db1)
self.elements.append(db2)
self.collect_profiling_data()
def get_env(self):
if self.visual_studio_versions:
vs_versions = self.visual_studio_versions
else:
vs_versions = [15, 14.1, 14, 13, 12, 11, 10, 9, 8]
if self.target_architecture:
arch = self.target_architecture
else:
arch = 'x86'
if sublime.arch() == 'x32':
host = 'x86'
elif sublime.arch() == 'x64':
host = 'amd64'
else:
sublime.error_message(
'Unknown Sublime architecture: %s' % sublime.arch())
return
if arch != host:
arch = host + '_' + arch
for version in vs_versions:
try:
vcvars = query_vcvarsall(version, arch)
if vcvars:
print('found vcvarsall for version', version)
return vcvars
except Exception:
print('could not find vsvcarsall for version', version)
continue
print('warning: did not find vcvarsall.bat')
return {}
def get_env(self):
if self.visual_studio_versions:
vs_versions = self.visual_studio_versions
else:
vs_versions = [15, 14.1, 14, 13, 12, 11, 10, 9, 8]
if self.target_architecture:
arch = self.target_architecture
else:
arch = 'x86'
if sublime.arch() == 'x32':
host = 'x86'
elif sublime.arch() == 'x64':
host = 'amd64'
else:
sublime.error_message(
'Unknown Sublime architecture: %s' % sublime.arch())
return
if arch != host:
arch = host + '_' + arch
for version in vs_versions:
try:
vcvars = query_vcvarsall(version, arch)
if vcvars:
print('found vcvarsall for version', version)
return vcvars
except Exception:
print('could not find vsvcarsall for version', version)
continue
print('warning: did not find vcvarsall.bat')
return {}
def get_env(self):
if self.visual_studio_versions:
vs_versions = self.visual_studio_versions
else:
vs_versions = [15, 14.1, 14, 13, 12, 11, 10, 9, 8]
if self.target_architecture:
arch = self.target_architecture
else:
arch = 'x86'
if sublime.arch() == 'x32':
host = 'x86'
elif sublime.arch() == 'x64':
host = 'amd64'
else:
sublime.error_message(
'Unknown Sublime architecture: %s' % sublime.arch())
return
if arch != host:
arch = host + '_' + arch
for version in vs_versions:
try:
vcvars = query_vcvarsall(version, arch)
if vcvars:
print('found vcvarsall for version', version)
return vcvars
except Exception:
print('could not find vsvcarsall for version', version)
continue
print('warning: did not find vcvarsall.bat')
return {}