Repository navigation
Expand file tree
/
Copy pathboxy_environment.py
More file actions
84 lines (69 loc) · 2.12 KB
/
Copy pathboxy_environment.py
File metadata and controls
84 lines (69 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: utf-8 -*-
"""
Boxy Theme Environment
"""
import sublime
import sublime_plugin
import textwrap
__version__ = '3.3.0
__pc_name__ = 'Boxy Theme'
def list2string(obj):
return '.'.join([str(x) for x in obj])
def format_version(module, attr, call=False):
try:
if call:
version = getattr(module, attr)()
else:
version = getattr(module, attr)
except Exception as e:
print(e)
version = 'Version could not be acquired!'
if not isinstance(version, str):
version = list2string(version)
return version
def is_installed_by_package_control():
settings = sublime.load_settings('Package Control.sublime-settings')
return str(__pc_name__ in set(settings.get('installed_packages', [])))
class BoxyEnvironmentCommand(sublime_plugin.ApplicationCommand):
def run(self):
info = {}
info['platform'] = sublime.platform()
info['version'] = sublime.version()
info['arch'] = sublime.arch()
info['boxy_version'] = __version__
info['pc_install'] = is_installed_by_package_control()
try:
import mdpopups
info['mdpopups_version'] = format_version(mdpopups, 'version', call=True)
except Exception:
info['mdpopups_version'] = 'Version could not be acquired!'
try:
import markdown
info['markdown_version'] = format_version(markdown, 'version')
except Exception:
info['markdown_version'] = 'Version could not be acquired!'
try:
import jinja2
info['jinja_version'] = format_version(jinja2, '__version__')
except Exception:
info['jinja_version'] = 'Version could not be acquired!'
try:
import pygments
info['pygments_version'] = format_version(pygments, '__version__')
except Exception:
info['pygments_version'] = 'Version could not be acquired!'
msg = textwrap.dedent(
'''\
- Boxy Theme: %(boxy_version)s
- Sublime Text: %(version)s
- Platform: %(platform)s
- Package Control: %(pc_install)s
- Dependencies:
* mdpopups: %(mdpopups_version)s
* markdown: %(markdown_version)s
* pygments: %(pygments_version)s
* jinja2: %(jinja_version)s
''' % info
)
sublime.message_dialog(msg + '\nInfo has been copied to the clipboard.')
sublime.set_clipboard(msg)