當前位置: 首頁>>代碼示例>>Python>>正文


Python TaskHandle.current_jobset方法代碼示例

本文整理匯總了Python中rope.base.taskhandle.TaskHandle.current_jobset方法的典型用法代碼示例。如果您正苦於以下問題:Python TaskHandle.current_jobset方法的具體用法?Python TaskHandle.current_jobset怎麽用?Python TaskHandle.current_jobset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rope.base.taskhandle.TaskHandle的用法示例。


在下文中一共展示了TaskHandle.current_jobset方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: PythonRefactorRename

# 需要導入模塊: from rope.base.taskhandle import TaskHandle [as 別名]
# 或者: from rope.base.taskhandle.TaskHandle import current_jobset [as 別名]
class PythonRefactorRename(sublime_plugin.TextCommand):

    def run(self, edit, block=False):
        self.view.run_command("save")
        self.original_loc = self.view.rowcol(self.view.sel()[0].a)
        with ropemate.ropecontext(self.view) as context:
            self.sel = self.view.sel()[0]
            word = self.view.substr(self.view.word(self.sel.b))

            self.rename = Rename(context.project, context.resource, self.sel.b)
            self.view.window().show_input_panel(
                "New name", word, self.new_name_entered, None, None)

    def new_name_entered(self, new_name):
        with ropemate.ropecontext(self.view) as context:
            if new_name is None or new_name == self.rename.old_name:
                return
            changes = self.rename.get_changes(new_name, in_hierarchy=True)
            self.handle = TaskHandle(name="rename_handle")
            self.handle.add_observer(self.refactoring_done)
            context.project.do(changes, task_handle=self.handle)

    def refactoring_done(self):
        percent_done = self.handle.current_jobset().get_percent_done()
        if percent_done == 100:
            self.view.run_command('revert')

            row, col = self.original_loc
            path = self.view.file_name() + ":%i:%i" % (row + 1, col + 1)
            self.view.window().open_file(
                path, sublime.ENCODED_POSITION)
開發者ID:hkukreja,項目名稱:SublimeRope,代碼行數:33,代碼來源:python_completions.py

示例2: ProgressHandler

# 需要導入模塊: from rope.base.taskhandle import TaskHandle [as 別名]
# 或者: from rope.base.taskhandle.TaskHandle import current_jobset [as 別名]
class ProgressHandler(object):

    """ Handle task progress. """

    def __init__(self, msg):
        self.handle = TaskHandle(name="refactoring_handle")
        self.handle.add_observer(self)
        self.message = msg

    def __call__(self):
        """ Show current progress. """
        percent_done = self.handle.current_jobset().get_percent_done()
        env.message('%s - done %s%%' % (self.message, percent_done))
開發者ID:zhaohuizh,項目名稱:dot-vim,代碼行數:15,代碼來源:rope.py

示例3: AbstractPythonRefactoring

# 需要導入模塊: from rope.base.taskhandle import TaskHandle [as 別名]
# 或者: from rope.base.taskhandle.TaskHandle import current_jobset [as 別名]
class AbstractPythonRefactoring(object):
    '''Some common functionality for the rope refactorings.
    Implement __init__, default_input, get_changes and
    create_refactoring_operation in the subclasses to add a new refactoring.'''
    def __init__(self, message):
        self.message = message

    def run(self, edit, block=False):
        self.view.run_command("save")
        self.original_loc = self.view.rowcol(self.view.sel()[0].a)
        with ropemate.context_for(self.view) as context:
            self.sel = self.view.sel()[0]

            self.refactoring = self.create_refactoring_operation(
                context.project, context.resource, self.sel.a, self.sel.b)
            self.view.window().show_input_panel(
                self.message,
                self.default_input(),
                self.input_callback,
                None,
                None
            )

    def input_callback(self, input_str):
        with ropemate.context_for(self.view) as context:
            if input_str is None:
                return
            changes = self.get_changes(input_str)
            self.handle = TaskHandle(name="refactoring_handle")
            self.handle.add_observer(self.refactoring_done)
            context.project.do(changes, task_handle=self.handle)

    def refactoring_done(self):
        percent_done = self.handle.current_jobset().get_percent_done()
        if percent_done == 100:
            self.view.run_command('revert')

            row, col = self.original_loc
            path = self.view.file_name() + ":%i:%i" % (row + 1, col + 1)
            self.view.window().open_file(path, sublime.ENCODED_POSITION)

    def default_input(self):
        raise NotImplementedError

    def get_changes(self, input_str):
        raise NotImplementedError

    def create_refactoring_operation(self, project, resource, start, end):
        raise NotImplementedError
開發者ID:Burekas,項目名稱:sublimeconf,代碼行數:51,代碼來源:sublime_rope.py

示例4: Worker

# 需要導入模塊: from rope.base.taskhandle import TaskHandle [as 別名]
# 或者: from rope.base.taskhandle.TaskHandle import current_jobset [as 別名]
        class Worker(threading.Thread):
            def __init__(self, view, context, changes):
                self.view = view
                self.context = context
                self.changes = changes
                self.handler = TaskHandle(name="organizer_imports_handler")
                self.handler.add_observer(self.finish)
                threading.Thread.__init__(self)

            def run(self):
                self.context.project.do(self.changes, task_handle=self.handler)

            def finish(self):

                percent_done = self.handler.current_jobset().get_percent_done()
                if percent_done == 100:
                    sublime.set_timeout(self.view.run_command("revert"), 10)
開發者ID:DamnWidget,項目名稱:SublimeRope,代碼行數:19,代碼來源:sublime_rope.py


注:本文中的rope.base.taskhandle.TaskHandle.current_jobset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。