python类status_message()的实例源码

BaseCommand.py 文件源码 项目:sublime-commandbox 作者: Ortus-Solutions 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def show_output_panel(self, text=''):
        if self.silent:
            self.status_message(text)
            return

        if self.results_in_new_tab:
            new_tab_path = os.path.join(self.commandbox_results_path(), "Commandbox Results")
            self.output_view = self.window.open_file(new_tab_path)
            self.output_view.set_scratch(True)
        else:
            self.output_view = self.window.get_output_panel("commandbox_output")
            self.show_panel()

        self.output_view.settings().set("scroll_past_end", False)
        self.add_syntax()
        self.appendToOutput(text)
ProgressNotifier.py 文件源码 项目:sublime-commandbox 作者: Ortus-Solutions 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def run(self, i):
        if self.stopped:
            return

        before = i % self.size
        after = (self.size - 1) - before

        sublime.status_message('%s [%s=%s]' % (self.message, ' ' * before, ' ' * after))

        if not after:
            self.addend = -1
        if not before:
            self.addend = 1
        i += self.addend

        sublime.set_timeout(lambda: self.run(i), 100)
commands.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def error_command(method):
    """
    A decorator that executes method only if the current view has errors.

    This decorator is meant to be used only with the run method of
    sublime_plugin.TextCommand subclasses.

    A wrapped version of method is returned.

    """

    def run(self, edit, **kwargs):
        vid = self.view.id()

        if vid in persist.errors and persist.errors[vid]:
            method(self, self.view, persist.errors[vid], persist.highlights[vid], **kwargs)
        else:
            sublime.status_message('No lint errors.')

    return run
BGS_PapyrusF4.py 文件源码 项目:Bethesda_SublimeFO4 作者: Scrivener07 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def openDiffInTab(viewHandle, edit, oldTextName, newTextName, oldText, newText):
    diffs = difflib.unified_diff(oldText.splitlines(), newText.splitlines(), oldTextName, newTextName)
    diffText = u"\n".join(line for line in diffs)

    if diffText == "":
        sublime.status_message("No changes between revisions.")
    else:
        scratch = viewHandle.window().new_file()
        scratch.set_scratch(True)
        scratch.set_name("{old} -> {new}".format(old = oldTextName, new = newTextName))
        scratch.set_syntax_file("Packages/Diff/Diff.tmLanguage")

        if (int(sublime.version()) >= 3000):
            scratch.run_command("append", {"characters": diffText})
        else:
            scratch.insert(edit, 0, diffText)
BGS_PapyrusF4.py 文件源码 项目:Bethesda_SublimeFO4 作者: Scrivener07 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def compilePapyrus(args, window, optimize, release, final):
    config = getPrefs(os.path.dirname(args["cmd"]))
    if config:
        scriptPath = args["cmd"][len(config["scripts"])+1:]

        args["cmd"] = [config["compiler"], scriptPath]
        args["cmd"].append("-f={0}".format(config["flags"]))
        args["cmd"].append("-i={0}".format(config["import"]))
        args["cmd"].append("-o={0}".format(config["output"]))
        if optimize:
            args["cmd"].append("-op")
        if release:
            args["cmd"].append("-r")
        if final:
            args["cmd"].append("-final")

        args["working_dir"] = os.path.dirname(config["compiler"])

        window.run_command("exec", args)
    else:
        sublime.status_message("No configuration for {0}".format(os.path.dirname(args["cmd"])))
Mp3Player.py 文件源码 项目:sublime-Mp3Player 作者: RachitKansal 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def run(self, edit):
        try:
            if(player.index == len(player.titles_list) - 1):
                player.index = 0
            else:
                player.index = player.index + 1

            if(os.path.exists(player.path_list[player.index]) == False):
                if(player.index == len(player.titles_list) - 1):
                    player.index = 0
                reload_lists()
            player.set_media(player.media_list_mod[player.index])
            sublime.status_message(player.titles_list[player.index])
            player.play()
        except Exception:
            sublime.status_message("Add a Song path")
threads.py 文件源码 项目:DXMate 作者: jtowers 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def run(self, i):
        if not self.thread.is_alive():
            if hasattr(self.thread, 'result') and not self.thread.result:
                sublime.status_message('')
                return
            sublime.status_message(self.success_message)
            if self.callback != None:
                self.callback()
            return

        before = i % self.size
        after = (self.size - 1) - before

        sublime.status_message('%s [%s=%s]' % \
            (self.message, ' ' * before, ' ' * after))

        if not after:
            self.addend = -1
        if not before:
            self.addend = 1
        i += self.addend

        sublime.set_timeout(lambda: self.run(i), 100)
utilities.py 文件源码 项目:sublimeplugins 作者: ktuan89 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def replace(self, query):
        if query.startswith("#"):
            query = query[1:]
            views = self.window.views()
        else:
            views = [self.window.active_view()]

        total = 0
        for view in views:
            original_string = view.substr(sublime.Region(0, view.size()))
            pp = '\\b' + self.original_text + '\\b'
            p = re.compile(pp)
            (new_string, count) = p.subn(query, original_string)
            total = total + count
            if new_string != original_string:
                view.run_command('replace_content', {"new_content": new_string})
        sublime.status_message("Replace {0} occurrences from {1} files".format(total, len(views)))
        pass
grep.py 文件源码 项目:sublimeplugins 作者: ktuan89 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def search(self, query):
        if self.grep_command is not None:
            command = self.grep_command.format(pipes.quote(query))
        elif self.show_in_view:
            command = grepFormatStr().format(
                grepPath(self.window),
                pipes.quote(query)
            )
        else:
            # we need quick results
            command = quickGrepFormatStr().format(
                grepPath(self.window),
                pipes.quote(query)
            )

        sublime.status_message("grepping {0} ...".format(pipes.quote(query)))

        output, _ = run_bash_for_output(command)
        lines = output.split('\n')
        self.show_results(query, lines)
code_map.py 文件源码 项目:sublime-codemap 作者: oleg-shilo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def run(self, edit):

        file = self.view.file_name()
        d = settings().get('depth')
        fD = Mapper.DEPTH[1]

        if file in fD and fD[file] < 4:
            fD[file] += 1
        elif d < 4:
            fD[file] = d + 1

        win().status_message('  Current CodeMap Depth: %d' % fD[file])
        refresh_map_for(self.view)
        synch_map(self.view)

# ===============================================================================
code_map.py 文件源码 项目:sublime-codemap 作者: oleg-shilo 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def run(self, edit):

        file = self.view.file_name()
        d = settings().get('depth')
        fD = Mapper.DEPTH[1]

        if file in fD and fD[file] > 0:
            fD[file] -= 1
        elif d > 0:
            fD[file] = d - 1

        win().status_message('  Current CodeMap Depth: %d' % fD[file])
        refresh_map_for(self.view)
        synch_map(self.view)

# ===============================================================================
SideBar.py 文件源码 项目:.sublime 作者: cxdongjack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def run(self, paths = []):
        items = []
        for item in SideBarSelection(paths).getSelectedImages():
            try:
                image_type, width, height = self.getImageInfo(item.path())
                items.append('<img src="'+item.pathAbsoluteFromProjectEncoded()+'" width="'+str(width)+'" height="'+str(height)+'">')
            except:
                items.append('<img src="'+item.pathAbsoluteFromProjectEncoded()+'">')
        if len(items) > 0:
            sublime.set_clipboard("\n".join(items));
            if len(items) > 1 :
                sublime.status_message("Items copied")
            else :
                sublime.status_message("Item copied")

    # http://stackoverflow.com/questions/8032642/how-to-obtain-image-size-using-standard-python-class-without-using-external-lib
SideBar.py 文件源码 项目:.sublime 作者: cxdongjack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def run(self, paths = []):
        items = []

        for item in SideBarSelection(paths).getSelectedItems():
            if item.isUnderCurrentProject():
                txt = item.url('url_production')
                try:
                    txt = urlunquote(txt.encode('utf8')).decode('utf8')
                except TypeError:
                    txt = urlunquote(txt)
                items.append(txt)

        if len(items) > 0:
            sublime.set_clipboard("\n".join(items));
            if len(items) > 1 :
                sublime.status_message("Items URL copied")
            else :
                sublime.status_message("Item URL copied")
Log Highlight.py 文件源码 项目:Log-Highlight 作者: poucotm 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_rel_path_file(self):
        # to support unsaved file (like Tail)
        logn = self.view.file_name()
        if logn:
            text = self.view.substr(sublime.Region(0, self.view.size()))
        else:
            logn = self.view.settings().get('filepath', '')
            text = fread(logn)

        files_l  = re.compile(LINK_REGX_RELPATH).findall(text)
        rel_path = False
        if len(files_l) > 0:
            for file_name in files_l:
                if not os.path.isabs(file_name):  # use the first in relative path list
                    rel_path = True
                    break
            if rel_path:
                return file_name
            else:
                sublime.status_message("Log Highlight : There is no relative path file")
                return ""
        else:
            sublime.status_message("Log Highlight : There is no openable file path")
            return ""
main.py 文件源码 项目:LSP 作者: tomv564 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def start_server(server_binary_args, working_dir, env):
    debug("starting " + str(server_binary_args))
    si = None
    if os.name == "nt":
        si = subprocess.STARTUPINFO()  # type: ignore
        si.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW  # type: ignore
    try:
        process = subprocess.Popen(
            server_binary_args,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            cwd=working_dir,
            env=env,
            startupinfo=si)
        return Client(process, working_dir)

    except Exception as err:
        sublime.status_message("Failed to start LSP server {}".format(str(server_binary_args)))
        exception_log("Failed to start server", err)
rpc.py 文件源码 项目:LSP 作者: tomv564 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def response_handler(self, response):
        handler_id = int(response.get("id"))  # dotty sends strings back :(
        if 'result' in response and 'error' not in response:
            result = response['result']
            if settings.log_payloads:
                debug('     ' + str(result))
            if handler_id in self._response_handlers:
                self._response_handlers[handler_id](result)
            else:
                debug("No handler found for id" + response.get("id"))
        elif 'error' in response and 'result' not in response:
            error = response['error']
            if settings.log_payloads:
                debug('     ' + str(error))
            if handler_id in self._error_handlers:
                self._error_handlers[handler_id](error)
            else:
                sublime.status_message(error.get('message'))
        else:
            debug('invalid response payload', response)
PyTest.py 文件源码 项目:PyTest 作者: kaste 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def alive_indicator():
    i = 0
    s = '----x----'
    c = [s[i:] + s[:i] for i in range(len(s))]

    # cycler = itertools.cycle(['|', '/', '-', '\\'])
    cycler = itertools.cycle(itertools.chain(c))

    def ping():
        nonlocal i
        i += 1
        if i % 10 == 0:
            try:
                msg = "%s %s" % (State['options'], State['target'])
            except KeyError:
                msg = ''
            sublime.status_message(
                'Running [%s] %s' % (next(cycler), msg))
    return ping
jediusages.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def process(self, usages: bool=False, data: Dict =None) -> None:
        """Process the definitions
        """

        view = self.text.view
        if not data['success']:
            sublime.status_message('Unable to find {}'.format(
                view.substr(view.word(view.sel()[0])))
            )
            return

        definitions = data['goto'] if not usages else data['usages']
        if len(definitions) == 0:
            sublime.status_message('Unable to find {}'.format(
                view.substr(view.word(view.sel()[0])))
            )
            return

        if definitions is not None and len(definitions) == 1 and not usages:
            self._jump(*definitions[0])
        else:
            self._show_options(definitions, usages)
progress_bar.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def update(self, i):
        """Update the progress bar
        """

        if self.die:
            return

        size = 8
        pos = i % size
        status = '{}={}'.format(' ' * pos, ' ' * ((size - 1) - pos))

        sublime.status_message('{} [{}]'.format(
            self.messages['start'], status)
        )

        if not (size - 1) - pos:
            self.addition = -1
        if not pos:
            self.addition = 1

        i += self.addition

        sublime.set_timeout_async(lambda: self.update(i), 100)
goto.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def on_success(self, data):
        """Called when a result comes from the query
        """

        if not data['result']:
            sublime.status_message('Could not find symbol')
            return

        symbols = []
        for result in data['result']:
            symbols.append({
                'title': result[0],
                'location': 'File: {} Line: {} Column: {}'.format(
                    result[1], result[2], result[3]
                ),
                'position': '{}:{}:{}'.format(result[1], result[2], result[3])
            })

        ExplorerPanel(self.view, symbols).show([])
mccabe.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def prepare_data(self, data: Dict[str, Any]) -> None:
        """Prepare the data to present in the quick panel
        """

        if not data['success'] or data['errors'] is None:
            sublime.status_message('Unable to run McCabe checker...')
            return

        if len(data['errors']) == 0:
            view = self.window.active_view()
            threshold = get_settings(view, 'mccabe_threshold', 7)
            sublime.status_message(
                'No code complexity beyond {} was found'.format(threshold)
            )

        self._show_options(data['errors'])
commands.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def error_command(method):
    """
    A decorator that executes method only if the current view has errors.

    This decorator is meant to be used only with the run method of
    sublime_plugin.TextCommand subclasses.

    A wrapped version of method is returned.

    """

    def run(self, edit, **kwargs):
        vid = self.view.id()

        if vid in persist.errors and persist.errors[vid]:
            method(self, self.view, persist.errors[vid], persist.highlights[vid], **kwargs)
        else:
            sublime.status_message('No lint errors.')

    return run
Project.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def compile_once(self, window_for_panel, triggered_for_file):

        if self.is_compiling and self.compiler is not None:
            if self.compiler.is_alive():
                sublime.status_message('Still compiling. Use Goto Anything > "ArcticTypescript: Terminate All Builds" to cancel.')
                self.compiler._show_output("")
            else:
                self.is_compiling = False

        if not self.is_compiling:
            self.is_compiling = True
            self.compiler = Compiler(self, window_for_panel, triggered_for_file)
            self.compiler.daemon = True

            sublime.status_message('Compiling')
            self.compiler.start()
Completion.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def prepare_list(self, tss_result_json):
        del self.completion_list[:]

        try:
            entries = json.loads(tss_result_json)
            entries = entries['entries']
        except:
            if tss_result_json.strip() == 'null':
                sublime.status_message('ArcticTypescript: no completions available')
            else:
                Debug('error', 'Completion request failed: %s' % tss_result_json)
            return 0

        for entry in entries:
            if self.interface and entry['kind'] != 'primitive type' and entry['kind'] != 'interface' : continue
            key = self._get_list_key(entry)
            value = self._get_list_value(entry)
            self.completion_list.append((key,value))

        self.completion_list.sort()
        return len(self.completion_list)


    # GET LISTE
ErrorsHighlighter.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def display_error_in_status_if_cursor(self, view):
        """
            Displays the error message in the sublime status
            line if the cursor is above an error (in source code).
            For the click on the error list, see T3SVIEWS.ERROR.on_click()
        """
        try:
            error = self._get_error_at(view.sel()[0].begin(), view.file_name())
        except:
            # no selection in view
            return
        if error is not None:
            sublime.status_message(error)
            self.previously_error_under_cursor = True
        elif self.previously_error_under_cursor: # only clear once
            sublime.status_message('')
            self.previously_error_under_cursor = False
issue.py 文件源码 项目:gissues 作者: divinites 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def run(self):
        issue_post = get_issue_post(self.view)
        log("preparing posting issue " + str(issue_post[
            'issue']))
        post_result = self.issue_list.post_issue(
            data=json.dumps(issue_post['issue']))
        if post_result.status_code in (200, 201):
            issue = post_result.json()
            if len(issue_post['label']) != 0:
                self.issue_list.attach_labels(issue['number'],
                                              issue_post['label'])
            repo_info = (self.issue_list.username, self.issue_list.repo_name,
                         None)
            self.view.settings().set("new_issue", False)
            print_issue_in_view = PrintIssueInView(
                self.issue_list, issue['number'], self.issue_storage,
                repo_info, repo_info_storage, self.view)
            print_issue_in_view.start()
        else:
            sublime.status_message(
                "Issue not Posted, error code {} please try again.".format(
                    str(post_result.status_code)))
plantuml.py 文件源码 项目:sublime-plantuml 作者: pkucmus 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def run(self, edit, *args):
        sublime.status_message('Processing PlantUML')
        self.view.set_status('plant', 'Processing PlantUML')
        content = self.view.substr(sublime.Region(0, self.view.size()))
        img_file_name = os.path.splitext(self.view.file_name())[0] + '.png'
        with open(img_file_name, 'w') as image_file:
            p = Popen(
                ['docker', 'run', '-i', '--rm', 'plantuml'],
                stdout=image_file, stdin=PIPE, stderr=PIPE
            )
            p.communicate(input=bytes(content, 'utf-8'))[0]

        view = self.find_view(img_file_name)
        if view is None:
            view = self.view
        view.window().open_file(img_file_name)
        view.window().focus_view(self.view)
        view.erase_status('plant')
vhdl_navigation.py 文件源码 项目:SmartVHDL 作者: TheClams 项目源码 文件源码 阅读 54 收藏 0 点赞 0 评论 0
def show(self,region,location):
        # If nothing is selected expand selection to word
        if region.empty() :
            region = self.view.word(region)
        # Make sure a whole word is selected
        elif (self.view.classify(region.a) & sublime.CLASS_WORD_START)==0 or (self.view.classify(region.b) & sublime.CLASS_WORD_END)==0:
            if (self.view.classify(region.a) & sublime.CLASS_WORD_START)==0:
                region.a = self.view.find_by_class(region.a,False,sublime.CLASS_WORD_START)
            if (self.view.classify(region.b) & sublime.CLASS_WORD_END)==0:
                region.b = self.view.find_by_class(region.b,True,sublime.CLASS_WORD_END)
        v = self.view.substr(region)
        # trigger on valid word only
        if not re.match(r'^[A-Za-z_]\w*$',v):
            return
        #
        s,ti = self.get_type(v,region)
        if not s:
            sublime.status_message('No definition found for ' + v)
        else :
            s = self.color_str(s,ti)
            s = '<style>{css}</style><div class="content">{txt}</div>'.format(css=tooltip_css, txt=s)
            self.view.show_popup(s,location=location, flags=tooltip_flag, max_width=500, on_navigate=self.on_navigate)
vhdl_module.py 文件源码 项目:SmartVHDL 作者: TheClams 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_list_file(self, projname, callback=None):
        global list_module_files
        global lmf_update_ongoing
        lmf_update_ongoing = True
        lmf = []
        for folder in sublime.active_window().folders():
            for root, dirs, files in os.walk(folder):
                for fn in files:
                    if fn.lower().endswith(('.vhd','.vho','.vhdl')):
                        ffn = os.path.join(root,fn)
                        f = open(ffn)
                        if os.stat(ffn).st_size:
                            s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
                            if s.find(b'entity') != -1:
                                lmf.append(ffn)
                            elif s.find(b'component') != -1:
                                lmf.append(ffn)
        sublime.status_message('List of module files updated')
        list_module_files[projname] = lmf[:]
        lmf_update_ongoing = False
        if callback:
            callback()
phpfmt.py 文件源码 项目:phpfmt_stable 作者: nanch 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def run(self, edit):
        def setIndentWithSpace(text):
            s = sublime.load_settings('phpfmt.sublime-settings')
            v = text.strip()
            if not v:
                v = False
            else:
                v = int(v)
            s.set("indent_with_space", v)
            sublime.save_settings('phpfmt.sublime-settings')
            sublime.status_message("phpfmt (indentation): done")
            sublime.active_window().active_view().run_command("fmt_now")

        s = sublime.load_settings('phpfmt.sublime-settings')
        spaces = s.get("indent_with_space", 4)
        if not spaces:
            spaces = ""
        spaces = str(spaces)
        self.view.window().show_input_panel('how many spaces? (leave it empty to return to tabs)', spaces, setIndentWithSpace, None, None)


问题


面经


文章

微信
公众号

扫码关注公众号