class ShortcutTracker:
    def __init__(self, replayScript):
        self.replayScript = replayScript
        self.unmatchedCommands = []
        self.reset()

    def reset(self):
        self.replayScript = ReplayScript(self.replayScript.name)
        self.currCommand = self.replayScript.getCommand()

    def updateCompletes(self, line):
        if line == self.currCommand:
            self.currCommand = self.replayScript.getCommand()
            return not self.currCommand
        else:
            self.unmatchedCommands += self.replayScript.getCommandsSoFar()
            self.unmatchedCommands.append(line)
            self.reset()
            return False

    def getNewCommands(self):
        self.reset()
        self.unmatchedCommands.append(self.replayScript.getShortcutName().lower())
        return self.unmatchedCommands
    
    def isLongerThan(self, otherTracker):
        return len(self.replayScript.commands) > len(otherTracker.replayScript.commands)
示例#2
0
 def respondRenameShortcut(self, dialog, responseId, nameEntry, oldValue):
     methodName = "ShortcutRename"
     newValue = nameEntry.get_text()
     if responseId == gtk.RESPONSE_ACCEPT:
         if self.checkShortcutName(dialog, newValue) and self.checkShortcutArguments(dialog, oldValue, newValue):
             self.shortcutManager.rename(oldValue, self.getShortcutFileName(newValue))
             oldValueRegexp = ReplayScript.transformToRegexp(oldValue)
             # Update shortcut name in shortcut files
             for _, shortcut in self.shortcutManager.getShortcuts():
                 if shortcut.getShortcutName() != newValue:
                     self.replaceInFile(shortcut.name, self.replaceShortcutName, oldValueRegexp, newValue)
             # Update shortcut name in current usecase file
             self.replaceInFile(self.fileName, self.replaceShortcutName, oldValueRegexp, newValue)
             print methodName, repr(oldValueRegexp), "renamed to", repr(newValue)
             self.initShortcutManager()
             self.updateShortcutNameInPreview(oldValueRegexp, newValue)
             dialog.hide()
         else:
             nameEntry.set_text(oldValue)
     else:
         dialog.hide()
 def reset(self):
     self.replayScript = ReplayScript(self.replayScript.name)
     self.currCommand = self.replayScript.getCommand()
示例#4
0
 def runShortcutCommands(self, recordScript, shortcut, args):
     shortcutCopy = ReplayScript(shortcut.name, True)
     while not shortcutCopy.hasTerminated():
         command = shortcutCopy.getCommand(args)
         self.recordShortcutCommand(recordScript, command)
示例#5
0
 def replaceArgs(matchobj):
     return ReplayScript.getTextWithArgs(newName, [arg for arg in matchobj.groups()])