This repository has been archived by the owner on Apr 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
pythonista_startup.py
99 lines (86 loc) · 2.53 KB
/
pythonista_startup.py
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!python3
#
# Must be added to:
#
# ~/Documents/site-packages-3
#
# Check blackmamba.config._DEFAULTS for default values
config = {
'general': {
'jedi': True
# Uncomment to disable keyboard shortcuts
# 'register_key_commands': False
},
'update': {
'enabled': True,
'interval': 3600
},
'file_picker': {
'ignore_folders': {
'': ['.git'],
'.': ['Pythonista', '.Trash', 'Examples',
'site-packages-2', 'site-packages', 'stash_extensions'],
'site-packages-3': ['blackmamba', 'bm-pip-backup'],
'Working Copy': ['bm-pip-backup']
}
},
'analyzer': {
'hud_alert_delay': 1.0,
'remove_whitespaces': True,
'flake8': [
# 1st pass
['--select=E901,E999,F821,F822,F823'],
# 2nd pass
['--max-complexity=10', '--max-line-length=127']
]
},
'tester': {
'hud_alert_delay': 1.0,
'hide_console': True
},
'drag_and_drop': {
'ignore_folders': {
'': ['.git'],
'.': ['Pythonista', '.Trash', 'Examples',
'site-packages-2', 'site-packages', 'stash_extensions'],
'Working Copy': ['bm-pip-backup']
}
}
}
def register_custom_shortcuts():
import blackmamba.ide.action as action
from blackmamba.uikit.keyboard import register_key_command, UIKeyModifier
# Launch `StaSh` (= custom action title) via Ctrl-S
action = action.get_action('StaSh')
if action:
def launch_stash():
action.run()
register_key_command(
'S',
UIKeyModifier.CONTROL,
launch_stash,
'Launch StaSh'
)
def main():
import blackmamba
import blackmamba.log as log
# Default value is INFO. Use ERROR if you'd like to make Black
# Mamba quiet. Only errors will be printed.
log.set_level(log.INFO)
# The only requirement is to call main(). You can omit `config=config`
# if you'd like to use default config.
blackmamba.main(config=config)
register_custom_shortcuts()
# If you'd like to hide console after Black Mamba starts, just uncomment
# following lines
# import console
# console.hide_output()
if __name__ == 'pythonista_startup':
import traceback
import appex
try:
if not appex.is_running_extension():
main()
except Exception:
print(traceback.format_exc())
print('Failed to process pythonista_startup.py')