本文整理匯總了Python中rope.base.taskhandle.TaskHandle類的典型用法代碼示例。如果您正苦於以下問題:Python TaskHandle類的具體用法?Python TaskHandle怎麽用?Python TaskHandle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TaskHandle類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PythonRefactorRename
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)
示例2: ProgressHandler
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))
示例3: AbstractPythonRefactoring
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
示例4: __init__
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)
示例5: new_name_entered
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)
示例6: input_callback
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)
示例7: Worker
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)
示例8: new_name_entered
def new_name_entered(self, new_name):
with ropemate.ropecontext(self.view) as context:
if new_name is None:
return
changes = self.extract.get_changes(new_name)
print changes
self.handle = TaskHandle(name="extract_handle")
self.handle.add_observer(self.refactoring_done)
context.project.do(changes, task_handle=self.handle)
示例9: __init__
def __init__(self, msg):
""" Init progress handler. """
self.handle = TaskHandle(name="refactoring_handle")
self.handle.add_observer(self)
self.message = msg
示例10: __init__
def __init__(self, msg):
self.handle = TaskHandle(name="refactoring_handle")
self.handle.add_observer(self)
self.message = msg