Beispiel #1
0
 def addHotKeysFromFile(self, filename):
     print("[Config] Parsing hotkeys config file: " +
           Parser.getShortFilePath(filename))
     if not os.path.exists(filename) or not os.path.isfile(filename):
         print("Error! %s file are not exists!" % filename)
         return
     stopParsing = False
     addedActions = list()
     for line in open(filename, "r"):
         command = su.trimComments(line)
         if not command:
             continue
         if command == TOKEN.END:
             self.key_bindings.append("#IfWinActive")
         elif command.startswith('[') and command.endswith(']'):
             if Parser.gotIgnoreToken(command, addedActions, filename):
                 break
             self.key_bindings.append("\n#IfWinActive " +
                                      Parser.getApp(command))
         elif command.startswith(TOKEN.BIND):
             if len(command.split(' ', 3)) != 4:
                 print("Error! failed to parse line: " + command)
                 continue
             (bind_token, key, action, data) = command.split(' ', 3)
             self.setHotKeyAction(key, action, data)
             addedActions.append(action)
         else:
             print("[addHotKeysFromFile] Error: Failed to parse string: " +
                   command)
 def addHotKeysFromFile(self, filename):
     print("[Config] Parsing hotkeys config file: " + Parser.getShortFilePath(filename))
     if not os.path.exists(filename) or not os.path.isfile(filename):
         print("Error! %s file are not exists!" % filename)
         return
     stopParsing = False
     addedActions = list()
     for line in open(filename, "r"):
         command = su.trimComments(line)
         if not command:
             continue
         if command == TOKEN.END:
             self.key_bindings.append("#IfWinActive")
         elif command.startswith('[') and command.endswith(']'):
             if Parser.gotIgnoreToken(command, addedActions, filename):
                 break
             self.key_bindings.append("\n#IfWinActive " + Parser.getApp(command))
         elif command.startswith(TOKEN.BIND):
             if len(command.split(' ', 3)) != 4:
                 print("Error! failed to parse line: " + command)
                 continue
             (bind_token, key, action, data) = command.split(' ', 3)
             self.setHotKeyAction(key, action, data)
             addedActions.append(action)
         else:
             print("[addHotKeysFromFile] Error: Failed to parse string: " + command)
Beispiel #3
0
    def addAutoCompleteFromFile(self, filename):
        print("[Config] Parsing autocomplete config file: " +
              Parser.getShortFilePath(filename))
        if not os.path.exists(filename) or not os.path.isfile(filename):
            print("Error! %s file are not exists!" % filename)
            return
        stopParsing = False
        applicationChosen = None
        autoCompleteAppData = None
        for line in open(filename, "r"):
            command = su.trimComments(line)
            if command:
                if command.startswith('[') and command.endswith(
                        ']'):  #Works only for selected application
                    if Parser.gotIgnoreToken(command, autoCompleteAppData,
                                             filename):
                        stopParsing = True
                    if applicationChosen and len(
                            autoCompleteAppData) or stopParsing:
                        print("[addAutoCompleteForApp] writing %s entries" %
                              len(autoCompleteAppData))
                        self.addAutoCompleteForApp(
                            application=applicationChosen,
                            data=autoCompleteAppData)
                        if stopParsing:
                            break
                    if command == TOKEN.END:
                        applicationChosen = None
                        continue

                    applicationChosen = Parser.getApp(command)
                    autoCompleteAppData = dict()
                    print("[addAutoCompleteForApp] Section for: " +
                          applicationChosen)
                    continue
                if applicationChosen:
                    if '==' in command:
                        keyAndCommand = command.split('==')
                        if len(keyAndCommand) != 2:
                            print("Error! failed to parse; " + command)
                            continue
                        autoCompleteAppData[
                            keyAndCommand[0]] = keyAndCommand[1]
                    else:
                        name = self.createTextAlias(command)
                        if name:
                            autoCompleteAppData[name] = command
                elif '==' in command:  #Works in all applications
                    keyAndCommand = command.split('==')
                    if len(keyAndCommand) != 2:
                        print("Error! failed to parse; " + command)
                        continue
                    status = self.addAutoComplete(keyAndCommand[0],
                                                  keyAndCommand[1])
                else:
                    status = self.addAutoCompleteSmart(command)
    def addAutoCompleteFromFile(self, filename):
        print("[Config] Parsing autocomplete config file: " + Parser.getShortFilePath(filename))
        if not os.path.exists(filename) or not os.path.isfile(filename):
            print("Error! %s file are not exists!" % filename)
            return
        stopParsing = False
        applicationChosen = None
        autoCompleteAppData = None
        for line in open(filename, "r"):
            command = su.trimComments(line)
            if command:
                if command.startswith('[') and command.endswith(']'): #Works only for selected application
                    if Parser.gotIgnoreToken(command, autoCompleteAppData, filename):
                        stopParsing = True
                    if applicationChosen and len(autoCompleteAppData) or stopParsing:
                        print("[addAutoCompleteForApp] writing %s entries" % len(autoCompleteAppData))
                        self.addAutoCompleteForApp(application=applicationChosen, data=autoCompleteAppData)
                        if stopParsing:
                            break
                    if command == TOKEN.END:
                        applicationChosen = None
                        continue

                    applicationChosen = Parser.getApp(command)
                    autoCompleteAppData = dict()
                    print("[addAutoCompleteForApp] Section for: " + applicationChosen)
                    continue
                if applicationChosen:
                    if '==' in command:
                        keyAndCommand = command.split('==')
                        if len(keyAndCommand) != 2:
                            print("Error! failed to parse; " + command)
                            continue
                        autoCompleteAppData[keyAndCommand[0]] = keyAndCommand[1]
                    else:
                        name = self.createTextAlias(command)
                        if name:
                            autoCompleteAppData[name] = command
                elif '==' in command: #Works in all applications
                    keyAndCommand = command.split('==')
                    if len(keyAndCommand) != 2:
                        print("Error! failed to parse; " + command)
                        continue
                    status = self.addAutoComplete(keyAndCommand[0], keyAndCommand[1])
                else:
                    status = self.addAutoCompleteSmart(command)