def _show_documentation(definition): reuse = get_config_value('documentation.reuse', True) frame = get_config_value('documentation.frame', (630, 110, 730, 350)) tag = '__blackmamba.show_documentation' if not reuse: tag += ':{}'.format(definition.full_name) manager = overlay.get_manager() o = manager.get_overlay(tag) if o: o.title = definition.name o.content_view.text = definition.docstring() o.expand() o.become_active() return tv = ui.TextView(text=definition.docstring(), background_color=get_theme_value('background_color'), text_color=get_theme_value('text_color'), font=get_editor_font()) tv.editable = False window_size = ui.get_window_size() x = frame[0] y = frame[1] width = min(window_size[0] - x - 12, frame[2]) height = min(window_size[1] - y - 12, frame[3]) manager.present(definition.name, tv, frame=(x, y, width, height), tag=tag)
def check(): if not get_config_value('update.enabled', True): return timestamp = _timestamp() last_check = _get_last_update_check() or timestamp if last_check + get_config_value('update.interval', 86400) > timestamp: return _set_last_update_check(timestamp) info('Checking for Black Mamba updates...') local_release = get_local_release() latest_release = _get_latest_release() if not latest_release: error('Failed to fetch latest release version info') return if local_release: if local_release['tag_name'] == latest_release['tag_name']: info('No updates available, you are up to date') return info('New version available, selfupdate.py will be executed') import blackmamba.ide.script as script if system.PYTHONISTA_BUNDLE_VERSION >= 311015: # 311015 introduced script queues, no need for delay delay = None else: delay = 0.5 script.run_script('site-packages-3/blackmamba/script/selfupdate.py', delay=delay) else: info('Missing installed version info, you should use the installer')
def main(): if not get_config_value('general.jedi', False): log.warn( 'find_usages disabled, you can enable it by setting general.jedi to True' ) return path = editor.get_path() if path is None: return if not path.endswith('.py'): return tab.save() text = editor.get_text() if not text: return line = source.get_line_number() column = source.get_column_index() if line is None or column is None: return script = jedi.api.Script(text, line, column, path) definitions = [d for d in script.usages() if d.module_path and d.line] if not definitions: console.hud_alert('Definition not found', 'error') return _select_location(definitions)
def ignore(folder, file): if file.startswith('.'): return True ignore_folders = get_config_value('drag_and_drop.ignore_folders', None) if not ignore_folders: return False for parent, folders in ignore_folders.items(): if not parent and file in folders: return True if parent == '.' and folder == os.path.expanduser( '~/Documents') and file in folders: return True if parent == os.path.basename(folder) and file in folders: return True return False
def main(): path = editor.get_path() if not path: return if not path.endswith('.py'): return editor.clear_annotations() flake8_options = get_config_value('analyzer.flake8', None) selection = editor.get_selection() text = _editor_text() if flake8_options: annotations = _flake8_annotations(os.path.abspath(path), flake8_options) else: annotations = _pep8_annotations(text, ignore=_ignore_codes(), max_line_length=_max_line_length()) annotations += _pyflakes_annotations(path, text) if not annotations: if selection: editor.set_selection(selection[0], scroll=True) console.hud_alert('No Issues Found', 'iob:checkmark_32', _hud_alert_delay()) return None scroll = True by_line = sorted(annotations, key=lambda x: x.line) for l, a in groupby(by_line, lambda x: x.line): _annotate(l, a, scroll) scroll = False
def _main(config=None): # It's here because Sphinx doesn't show documentation for decorated # functions from blackmamba.config import update_config_with_dict, get_config_value import sys info('Black Mamba initialization...') if system.PYTHONISTA_BUNDLE_VERSION < 320000: error('Black Mamba supports Pythonista >= 3.2 only.') return if not sys.version_info.major == 3: error('Black Mamba supports Python 3 only') return if sys.version_info.minor < 6: error('Black Mamba support Python 3.6+ only') return if config: update_config_with_dict(config) _check_compatibility() if get_config_value('general.register_key_commands', True): _register_default_key_commands() _register_ios11_default_key_commands() info('Black Mamba initialized') _check_for_updates()
def _remove_whitespaces(): return get_config_value('analyzer.remove_whitespaces', True)
def _max_line_length(): return get_config_value('analyzer.max_line_length', 79)
def _ignore_codes(): return get_config_value('analyzer.ignore_codes', ['W391', 'W293'])
def _hud_alert_delay(): return get_config_value('analyzer.hud_alert_delay', 1.0)
def _ignore_folders(): return get_config_value('file_picker.ignore_folders', _IGNORE_FOLDERS)
def page_down(): scroll_to_line(get_config_value('general.page_line_count', 40), True)
def _hide_console(): return get_config_value('tester.hide_console', True)
def _hud_alert_delay(): return get_config_value('tester.hud_alert_delay', 1.0)