Beispiel #1
0
    def process_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message('You have to provide valid arguments'
                                   ' for this restructure. Cancelling...')
            return

        try:
            self.args.append(ast.literal_eval(input_str))
        except:
            sublime.error_message('Malformed string detected in Args.\n\n'
                                  'The Args value must be a Python dictionary')
            return

        with ropemate.context_for(self.view) as context:
            self.refactoring = Restructure(context.project, self.args[0],
                                           self.args[1], self.args[2])

            self.changes = self.refactoring.get_changes()

            try:
                context.project.do(self.changes)
                # sublime.error_message(self.changes.get_description())
                print "RESTRUCTURING CHANGES PERFORMED"
                print "-------------------------------"
                print self.changes.get_description()
                print "-------------------------------"
            except ModuleNotFoundError, e:
                sublime.error_message(e)
def main():
    prj = Project(os.path.realpath("../shuup/core/models"))
    rst = Restructure(prj, "_(${str})", "")
    rst.template = LanguageTwist("./shuup_fi_to_en.po")

    twist_set = rst.get_changes()

    for chg in twist_set.changes:
        print(chg.get_description())  # noqa

    prj.do(twist_set)
Beispiel #3
0
def main():
    prj = Project(os.path.realpath("../shuup/core/models"))
    rst = Restructure(prj, "_(${str})", "")
    rst.template = LanguageTwist("./shuup_fi_to_en.po")

    twist_set = rst.get_changes()

    for chg in twist_set.changes:
        print(chg.get_description())

    prj.do(twist_set)
Beispiel #4
0
class PythonRefactorRestructure(sublime_plugin.TextCommand):
    '''Reestruture coincidences'''
    def run(self, edit, block=False):
        self.messages = ['Pattern', 'Goal', 'Args']
        self.defaults = ["${}", "${}", "{'': 'name='}"]
        self.args = []

        self.view.run_command("save")
        self._window = self.view.window()
        self._window.show_input_panel(self.messages[0], self.defaults[0],
                                      self.get_goal, None, None)

    def get_goal(self, input_str):
        if input_str in self.defaults:
            sublime.status_message('You have to provide a valid pattern'
                                   ' for this restructure. Cancelling...')
            return

        self.args.append(str(input_str))
        self._window.show_input_panel(self.messages[1], self.defaults[1],
                                      self.get_args, None, None)

    def get_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message('You have to provide valid arguments'
                                   ' for this restructure. Cancelling...')
            return

        self.args.append(str(input_str))
        self._window.show_input_panel(self.messages[2], self.defaults[2],
                                      self.process_args, None, None)

    def process_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message('You have to provide valid arguments'
                                   ' for this restructure. Cancelling...')
            return

        try:
            self.args.append(ast.literal_eval(input_str))
        except:
            sublime.error_message('Malformed string detected in Args.\n\n'
                                  'The Args value must be a Python dictionary')
            return

        with ropemate.context_for(self.view) as context:
            self.refactoring = Restructure(context.project, self.args[0],
                                           self.args[1], self.args[2])

            self.changes = self.refactoring.get_changes()

            try:
                context.project.do(self.changes)
                # sublime.error_message(self.changes.get_description())
                print "RESTRUCTURING CHANGES PERFORMED"
                print "-------------------------------"
                print self.changes.get_description()
                print "-------------------------------"
            except ModuleNotFoundError, e:
                sublime.error_message(e)
Beispiel #5
0
    def process_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message(
                'You have to provide valid arguments'
                ' for this restructure. Cancelling...')
            return

        try:
            self.args.append(ast.literal_eval(input_str))
        except:
            sublime.error_message(
                'Malformed string detected in Args.\n\n'
                'The Args value must be a Python dictionary')
            return

        with ropemate.context_for(self.view) as context:
            self.refactoring = Restructure(
                context.project, self.args[0], self.args[1], self.args[2])

            self.changes = self.refactoring.get_changes()

            try:
                context.project.do(self.changes)
                # sublime.error_message(self.changes.get_description())
                print "RESTRUCTURING CHANGES PERFORMED"
                print "-------------------------------"
                print self.changes.get_description()
                print "-------------------------------"
            except ModuleNotFoundError, e:
                sublime.error_message(e)
Beispiel #6
0
class PythonRefactorRestructure(sublime_plugin.TextCommand):
    """Reestruture coincidences"""

    def run(self, edit, block=False):
        self.messages = ["Pattern", "Goal", "Args"]
        self.defaults = ["${}", "${}", "{'': 'name='}"]
        self.args = []

        self.view.run_command("save")
        self._window = self.view.window()
        self._window.show_input_panel(self.messages[0], self.defaults[0], self.get_goal, None, None)

    def get_goal(self, input_str):
        if input_str in self.defaults:
            sublime.status_message("You have to provide a valid pattern" " for this restructure. Cancelling...")
            return

        self.args.append(str(input_str))
        self._window.show_input_panel(self.messages[1], self.defaults[1], self.get_args, None, None)

    def get_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message("You have to provide valid arguments" " for this restructure. Cancelling...")
            return

        self.args.append(str(input_str))
        self._window.show_input_panel(self.messages[2], self.defaults[2], self.process_args, None, None)

    def process_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message("You have to provide valid arguments" " for this restructure. Cancelling...")
            return

        try:
            self.args.append(ast.literal_eval(input_str))
        except:
            sublime.error_message("Malformed string detected in Args.\n\n" "The Args value must be a Python dictionary")
            return

        with ropemate.context_for(self.view) as context:
            self.refactoring = Restructure(context.project, self.args[0], self.args[1], self.args[2])

            self.changes = self.refactoring.get_changes()

            try:
                context.project.do(self.changes)
                # sublime.error_message(self.changes.get_description())
                print "RESTRUCTURING CHANGES PERFORMED"
                print "-------------------------------"
                print self.changes.get_description()
                print "-------------------------------"
            except ModuleNotFoundError, e:
                sublime.error_message(e)
    def process_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message('You will provide valid arguments for this'
                ' renstructure. Cancelling...')
            return

        try:
            self.args.append(ast.literal_eval(input_str))
        except:
            sublime.error_message("Malformed string detected in Args.\n\n"
                "The Args value must be a Python dictionary")
            return

        with ropemate.context_for(self.view) as context:
            self.refactoring = Restructure(
                context.project, self.args[0], self.args[1], self.args[2])

            self.changes = self.refactoring.get_changes()

            try:
                context.project.do(self.changes)
                sublime.error_message(self.changes.get_description())
            except ModuleNotFoundError, e:
                sublime.error_message(e)
class PythonRefactorRestructure(sublime_plugin.TextCommand):
    '''Reestruture coincidences'''

    def run(self, edit, block=False):
        self.messages = ['Pattern', 'Goal', 'Args']
        self.defaults = ["${}", "${}", "{'': 'name='}"]
        self.args = []

        self.view.run_command("save")
        self.original_loc = self.view.rowcol(self.view.sel()[0].a)
        self._window = self.view.window()
        self._window.show_input_panel(
            self.messages[0], self.defaults[0], self.get_goal,
            None, None
        )

    def get_goal(self, input_str):
        if input_str in self.defaults:
            sublime.status_message('You will provide valid pattern for this'
                ' restructure. Cancelling...')
            return

        self.args.append(str(input_str))
        self._window.show_input_panel(
            self.messages[1], self.defaults[1], self.get_args,
            None, None
        )

    def get_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message('You will provide valid arguments for this'
                ' restructure. Cancelling...')
            return

        self.args.append(str(input_str))
        self._window.show_input_panel(
            self.messages[2], self.defaults[2], self.process_args,
            None, None
        )

    def process_args(self, input_str):
        if input_str in self.defaults:
            sublime.status_message('You will provide valid arguments for this'
                ' renstructure. Cancelling...')
            return

        try:
            self.args.append(ast.literal_eval(input_str))
        except:
            sublime.error_message("Malformed string detected in Args.\n\n"
                "The Args value must be a Python dictionary")
            return

        with ropemate.context_for(self.view) as context:
            self.refactoring = Restructure(
                context.project, self.args[0], self.args[1], self.args[2])

            self.changes = self.refactoring.get_changes()

            try:
                context.project.do(self.changes)
                sublime.error_message(self.changes.get_description())
            except ModuleNotFoundError, e:
                sublime.error_message(e)