Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 276f07c

Browse files
committed
feat(pip): improvements before the release
1 parent e95215c commit 276f07c

16 files changed

+59
-37
lines changed
File renamed without changes.

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,44 @@ An easy solution to fix typos!
44

55
Check the `words` folder for the languages available.
66

7-
## Required Installation
7+
## Installation
88
```
99
pip3 install keyboard
10+
pip3 install syntaxautofix
1011
```
1112
For the UI is required PyQt5.
1213

1314
## How to use with Target Language(s)
1415
- For English only
1516
```
16-
syntaxalert.py -words ./words/en.json
17+
syntaxautofix -words ./words/en.json
1718
```
1819

1920
- For Italian/English/Spanish (or without parameters is the same):
2021
```
21-
syntaxalert.py -words ./words/en.json -words2 ./words/it.json
22+
syntaxautofix -words ./words/en.json -words2 ./words/it.json
2223
```
23-
<br>
24-
24+
25+
- Otherwise with the `configini` parameter you can specify a settings file (sample in the package/repo):
26+
```
27+
syntaxautofix -configini /path/config.ini
28+
```
29+
30+
2531
## Adding New Terms
32+
33+
This require the git repo or the right path to the pip package folder.
34+
2635
```
2736
manageterms.py -wrong="wdiget" -right="widget" -lang=en
2837
```
2938

3039
You can use also an ui for that: `manageterms-gui.py`
3140

3241
## Adding New Terms using CSV File
42+
43+
This require the git repo or the right path to the pip package folder.
44+
3345
Directly upload new terms using a CSV file with row format:
3446
```
3547
<correct-term>, <wrong-term>

SyntaxAutoFix/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from . import syntaxalert
1+
from . import syntaxautofix
22
from .utils import *
File renamed without changes.

SyntaxAutoFix/syntaxalert.py renamed to SyntaxAutoFix/syntaxautofix.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/python3
22
import keyboard
3-
import argparse, os.path
3+
import argparse
4+
import os.path
45
from threading import Thread
56
from time import sleep
67
from SyntaxAutoFix.utils import open_typo_file
@@ -10,12 +11,7 @@
1011
import json
1112

1213
script_path = os.path.dirname(os.path.realpath(__file__))
13-
1414
config_parser = ConfigParser()
15-
config_parser.read(os.path.join(script_path, 'filepath.ini'))
16-
17-
LIST_OF_FILES = json.loads(config_parser.get('DEFAULT', 'words_file'))
18-
WORDS_FILE_DEFAULT_LOCATION = [os.path.join(script_path, file_path) for file_path in LIST_OF_FILES]
1915

2016

2117
# Load words
@@ -24,17 +20,22 @@ def loadWord(filename):
2420
words = open_typo_file(json_file)
2521
return words
2622

23+
2724
# Parse argument
2825
parser = argparse.ArgumentParser(description='Scan your digited letter for wrong words and alert you!')
29-
parser.add_argument('-words', dest='words_file', nargs='?', default=WORDS_FILE_DEFAULT_LOCATION[0], type=str)
30-
parser.add_argument('-words2', dest='words_file2', nargs='?', default=WORDS_FILE_DEFAULT_LOCATION[1], type=str)
26+
parser.add_argument('-config', dest='configini', nargs='?', default=os.path.join(script_path, 'config.ini'), type=str)
27+
parser.add_argument('-words', dest='words_file', nargs='?', default=os.path.join(script_path, 'words/en.json'), type=str)
28+
parser.add_argument('-words2', dest='words_file2', nargs='?', default=os.path.join(script_path, 'words/it.json'), type=str)
3129
args = parser.parse_args()
3230

31+
config_parser.read(args.configini)
32+
LIST_OF_FILES = json.loads(config_parser.get('DEFAULT', 'words_file'))
33+
WORDS_FILE_DEFAULT_LOCATION = [os.path.join(script_path, file_path) for file_path in LIST_OF_FILES]
34+
3335
# it holds the files name passed and the stat os file
3436
files = {}
3537

3638

37-
3839
def mispell_callback():
3940
recorded_words = keyboard.stop_recording()
4041
recorded_words_list = list(keyboard.get_typed_strings(recorded_words))

SyntaxAutoFix/words/en.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,6 @@
594594
"Turkey": [
595595
"Turky"
596596
],
597-
"Twitter": [
598-
"twitter"
599-
],
600597
"Ukraine": [
601598
"Ukrane"
602599
],
@@ -2006,10 +2003,6 @@
20062003
"behavour",
20072004
"behaviour"
20082005
],
2009-
"behaviour": [
2010-
"behavour",
2011-
"bheaviour"
2012-
],
20132006
"being": [
20142007
"bieng"
20152008
],
@@ -13464,4 +13457,4 @@
1346413457
"learning": [
1346513458
"lerning"
1346613459
]
13467-
}
13460+
}

SyntaxAutoFix/words/it.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,6 @@
486486
"hannio",
487487
"hano"
488488
],
489-
"regolmaneto": [
490-
"regolamento"
491-
],
492489
"produzione": [
493490
"produzioen"
494491
],
@@ -1501,4 +1498,4 @@
15011498
"accesso": [
15021499
"acecsso"
15031500
]
1504-
}
1501+
}

config-sample.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; Default values.
2+
[DEFAULT]
3+
words_file = [ "words/en.json", "words/it.json" ]

SyntaxAutoFix/csvtoterms.py renamed to csvtoterms.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python3
2-
import argparse, os.path, csv
2+
import argparse
3+
import os.path
4+
import csv
35
from SyntaxAutoFix.utils import open_typo_file, save_typo_data
46

57
# Parse argument
@@ -9,7 +11,8 @@
911
parser.add_argument('-lang', dest="lang", type=str, required=True)
1012
args = parser.parse_args()
1113

12-
script_path = os.path.dirname(os.path.realpath(__file__)) + '/words/' + args.lang + '.json'
14+
script_path = os.path.dirname(os.path.realpath(__file__))
15+
script_path = os.path.join(script_path, 'SyntaxAutoFix/words/' + args.lang + '.json')
1316

1417
typo_data = open_typo_file(script_path)
1518
with open(args.file) as csv_file:

launch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python3
2+
# This script can be used for who use the git version
3+
4+
import SyntaxAutoFix.syntaxautofix
5+
6+
SyntaxAutoFix.syntaxautofix.main()

0 commit comments

Comments
 (0)