Example #1
0
def loadJSON():
    # Check the file and load it
    if os.path.isfile(args.words_file) is False:
        print('ERR: Words file not exist!')
        exit()

    if args.words_file2 is not None:
        if os.path.isfile(args.words_file2) is not False:
            words = open_typo_file(args.words_file)
            words2 = open_typo_file(args.words_file2)
            words.update(words2)
            # register the status of file in these moment
            files[args.words_file] = os.stat(args.words_file)
            files[args.words_file2] = os.stat(args.words_file2)
    else:
        words = open_typo_file(args.words_file)
        # register the status of file in these moment
        files[args.words_file] = os.stat(args.words_file)

    print(str(len(words)) + " words loaded")
    for (correct, wrongs) in words.items():
        for wrong in wrongs:
            if wrong != '':
                print('Loaded ' + wrong + ' with as: ' + correct)
                keyboard.add_abbreviation(wrong, ' ' + correct + ' ')
                keyboard.add_word_listener(wrong, mispell_callback)
Example #2
0
def load_language(_args_):
    try:
        lang_path = script_path + '/words/' + _args_.lang + '.json'
        words = open_typo_file(lang_path)
        return words
    except FileNotFoundError:
        raise ValueError('Language ' + _args_.lang +
                         ' actually not avalaible.')
Example #3
0
def store_new_argument(_args_):
  try:
    lang_path = script_path + '/words/' + _args_.lang + '.json'
    typo_data = open_typo_file(lang_path)
    typo_data[args.right].add(_args_.wrong)
    save_typo_data(lang_path, typo_data)
  except FileNotFoundError:
    raise ValueError('SyntaxAlert only supports en, es, fr, it at the moment.')
Example #4
0
    def store_new_argument(self):
        wrong = self.ui.wrong.text()
        right = self.ui.right.text()
        lang = self.ui.languages.currentText()
        # Check argument is not circular
        if right == wrong:
            msg = QErrorMessage(self)
            msg.setWindowModality(QtCore.Qt.WindowModal)
            msg.showMessage(
                'You can’t replace a word with itself. It will create a loop.')

        lang_path = self.script_path + lang + '.json'
        typo_data = open_typo_file(lang_path)
        typo_data[right].add(wrong)
        save_typo_data(lang_path, typo_data)
Example #5
0
def loadWord(filename):
    with open(filename) as json_file:
        words = open_typo_file(json_file)
        return words
Example #6
0
#!/usr/bin/env python3
import argparse, os.path, json, csv
from utils.data_handlers import open_typo_file, save_typo_data

# Parse argument
parser = argparse.ArgumentParser(description='add new terms!')

parser.add_argument('-file', dest="file", type=str, required=True)
parser.add_argument('-lang', dest="lang", type=str, required=True)
args = parser.parse_args()

script_path = os.path.dirname(
    os.path.realpath(__file__)) + '/words/' + args.lang + '.json'

typo_data = open_typo_file(script_path)
with open(args.file) as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    for row in csv_reader:
        typo_data[row[0]].add(row[1])

save_typo_data(script_path, typo_data)
#!/usr/bin/env python3
import argparse, os.path
from utils.data_handlers import open_typo_file, save_typo_data

# Parse argument
parser = argparse.ArgumentParser(description='add new terms!')

parser.add_argument('-wrong', dest="wrong", type=str, required=True)
parser.add_argument('-right', dest="right", type=str, required=True)
parser.add_argument('-lang', dest="lang", type=str, required=True)
args = parser.parse_args()

script_path = os.path.dirname(os.path.realpath(__file__))
lang_path = script_path + '/words/' + args.lang + '.json'

typo_data = open_typo_file(lang_path)
typo_data[args.right].add(args.wrong)

save_typo_data(lang_path, typo_data)