Beispiel #1
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.')
Beispiel #2
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)
Beispiel #3
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)
Beispiel #5
0
#!/usr/bin/env python3
import argparse, os.path, json
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__)) + '/words/' + args.lang + '.json'

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

save_typo_data(typo_data, script_path)