Skip to content

Commit 2880f93

Browse files
authored
Update to v0.5.0
1 parent d4d3bbe commit 2880f93

File tree

9 files changed

+326
-36
lines changed

9 files changed

+326
-36
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ love:
4747
man/${NAME}.${SECTION}.gz: man/${NAME}.${SECTION}
4848
@gzip -k9c man/${NAME}.${SECTION} > man/${NAME}.${SECTION}.gz
4949

50+
src/${NAME}/po/en/${NAME}.mo:
51+
@msgfmt --output-file=src/${NAME}/po/en/${NAME}.mo src/${NAME}/po/en/${NAME}.po
52+
5053
src/${NAME}/po/fr/${NAME}.mo:
5154
@msgfmt --output-file=src/${NAME}/po/fr/${NAME}.mo src/${NAME}/po/fr/${NAME}.po
5255

53-
package: man/${NAME}.${SECTION}.gz src/${NAME}/po/fr/${NAME}.mo
56+
package: man/${NAME}.${SECTION}.gz src/${NAME}/po/en/${NAME}.mo src/${NAME}/po/fr/${NAME}.mo
5457
python -m build
5558

5659
upload-test:
@@ -60,5 +63,5 @@ upload:
6063
python -m twine upload dist/*
6164

6265
distclean:
63-
rm -rf build dist man/${NAME}.${SECTION}.gz src/${NAME}/po/fr/${NAME}.mo src/*.egg-info
66+
rm -rf build dist man/${NAME}.${SECTION}.gz src/${NAME}/po/en/${NAME}.mo src/${NAME}/po/fr/${NAME}.mo src/*.egg-info
6467

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ conjuguer — conjugaison des verbes Francais
1111
\[-c|--columns NUM\]
1212
\[-d|--dictionary PATH\]
1313
\[-n|--nocolor\]
14+
\[-D|--DELA\]
15+
\[-A|--ABU\]
1416
\[--debug\]
1517
\[--help|-?\]
18+
\[--locale LANG\]
1619
\[--version\]
1720
\[--\]
1821
verb [...]
@@ -36,6 +39,8 @@ Options | Use
3639
-c\|--columns NUM|Choose number of columns to display between 1, 2 or 4
3740
-d\|--dictionary PATH|Select a specific dictionary
3841
-n\|--nocolor|Disable color output
42+
-D\|--DELA|Enable DELA format output
43+
-A\|--ABU|Enable ABU format output
3944
--debug|Enable debug mode
4045
--help\|-?|Print usage and a short help message and exit
4146
--locale LANG|Override environment to select another language
@@ -94,5 +99,3 @@ the verbs conjugated with the "être" auxiliary when used with a pronoun for exa
9499
Though the software is probably mostly correct, I will consider it as Beta quality
95100
till I get a better idea of the quality of the source data and offer a way to improve it...
96101

97-
The *--lang* command line option does not always work correctly when selecting en(glish).
98-

man/conjuguer.1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
.Op Fl c|--columns Ar NUM
1010
.Op Fl d|--dictionary Ar PATH
1111
.Op Fl n|--nocolor
12+
.Op Fl D|--DELA
13+
.Op Fl A|--ABU
1214
.Op Fl -debug
1315
.Op Fl -help|-?
16+
.Op Fl -locale Ar LANG
1417
.Op Fl -version
1518
.Op Fl -
1619
.Ar verb
@@ -45,6 +48,12 @@ Select a specific dictionary
4548
.Op Fl n|--nocolor
4649
Disable color output
4750
.Pp
51+
.Op Fl D|--DELA
52+
Enable DELA format output
53+
.Pp
54+
.Op Fl A|--ABU
55+
Enable ABU format output
56+
.Pp
4857
.Op Fl -debug
4958
Enable debug mode
5059
.Pp
@@ -118,7 +127,3 @@ the verbs conjugated with the "etre" auxiliary when used with a pronoun for exam
118127
.Pp
119128
Though the software is probably mostly correct, I will consider it as Beta quality till I get
120129
a better idea of the quality of the source data and offer a way to improve it...
121-
.Pp
122-
The
123-
.Fl -lang
124-
command line option does not always work correctly when selecting en(glish).

setup.cfg

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = pnu_conjuguer
33
description = conjugaison des verbes Français
44
long_description = file: README.md
55
long_description_content_type = text/markdown
6-
version = 0.4.0
6+
version = 0.5.0
77
license = BSD 3-Clause License
88
license_files = License
99
author = Hubert Tournier
@@ -24,9 +24,6 @@ classifiers =
2424
Operating System :: POSIX :: BSD :: FreeBSD
2525
Operating System :: Microsoft :: Windows
2626
Programming Language :: Python :: 3
27-
Programming Language :: Python :: 3.0
28-
Programming Language :: Python :: 3.1
29-
Programming Language :: Python :: 3.2
3027
Programming Language :: Python :: 3.3
3128
Programming Language :: Python :: 3.4
3229
Programming Language :: Python :: 3.5
@@ -44,7 +41,7 @@ classifiers =
4441
package_dir =
4542
= src
4643
packages = find:
47-
python_requires = >=3.0
44+
python_requires = >=3.3
4845
install_requires =
4946
colorama
5047
dict-fr-AU-DELA
@@ -60,6 +57,8 @@ console_scripts =
6057
[options.data_files]
6158
man/man1 =
6259
man/conjuguer.1.gz
60+
share/locale/en/LC_MESSAGES =
61+
src/conjuguer/po/en/conjuguer.mo
6362
share/locale/fr/LC_MESSAGES =
6463
src/conjuguer/po/fr/conjuguer.mo
6564

src/conjuguer/Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,30 @@ po/${NAME}.pot:
5050
@mkdir po
5151
@xgettext --language=Python -o po/${NAME}.pot *.py
5252

53+
po/en/${NAME}.po: po/${NAME}.pot
54+
@mkdir -p po/en
55+
@msginit --locale=en --input=po/${NAME}.pot --output=po/en/${NAME}.po
56+
57+
po/en/${NAME}.mo: po/en/${NAME}.po
58+
@msgfmt --output-file=po/en/${NAME}.mo po/en/${NAME}.po
59+
5360
po/fr/${NAME}.po: po/${NAME}.pot
5461
@mkdir -p po/fr
5562
@msginit --locale=fr --input=po/${NAME}.pot --output=po/fr/${NAME}.po
5663

5764
po/fr/${NAME}.mo: po/fr/${NAME}.po
5865
@msgfmt --output-file=po/fr/${NAME}.mo po/fr/${NAME}.po
5966

60-
install: ${NAME}.${SECTION}.gz po/fr/${NAME}.mo
67+
install: ${NAME}.${SECTION}.gz po/en/${NAME}.mo po/fr/${NAME}.mo
6168
install -m 0755 -o root -g wheel main.py ${DESTROOTDIR}/bin/${NAME}
6269
install -m 0644 -o root -g wheel ${NAME}.${SECTION}.gz ${DESTROOTDIR}/man/man${SECTION}
70+
install -m 0644 -o root -g wheel po/en/${NAME}.mo ${DESTROOTDIR}/share/locale/en/LC_MESSAGES
6371
install -m 0644 -o root -g wheel po/fr/${NAME}.mo ${DESTROOTDIR}/share/locale/fr/LC_MESSAGES
6472

6573
uninstall:
6674
rm -f ${DESTROOTDIR}/bin/${NAME}
6775
rm -f ${DESTROOTDIR}/man/man${SECTION}/${NAME}.${SECTION}.gz
76+
rm -f ${DESTROOTDIR}/share/locale/en/LC_MESSAGES/${NAME}.mo
6877
rm -f ${DESTROOTDIR}/share/locale/fr/LC_MESSAGES/${NAME}.mo
6978

7079
whatis:
@@ -74,7 +83,7 @@ love:
7483
@echo "Not war!"
7584

7685
clean:
77-
@rm -f ${NAME}.${SECTION}.gz po/fr/${NAME}.mo
86+
@rm -f ${NAME}.${SECTION}.gz po/en/${NAME}.mo po/fr/${NAME}.mo
7887

7988
distclean: clean
8089

src/conjuguer/main.py

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Author: Hubert Tournier
55
"""
66

7+
import collections
78
import copy
89
import getopt
910
import gettext
@@ -20,14 +21,16 @@
2021
from .blank import blank_verb
2122

2223
# Version string used by the what(1) and ident(1) commands:
23-
ID = "@(#) $Id: conjuguer - conjugaison des verbes Français v0.4.0 (October 2, 2021) by Hubert Tournier $"
24+
ID = "@(#) $Id: conjuguer - conjugaison des verbes Français v0.5.0 (October 3, 2021) by Hubert Tournier $"
2425

2526
# Default parameters. Can be overcome by environment variables, then command line options
2627
parameters = {
2728
"Dictionary path": "",
2829
"Dictionary type": "",
2930
"Color display": True,
3031
"Display columns": 4,
32+
"DELA output": False,
33+
"ABU output": False,
3134
"DictPath": [],
3235
}
3336

@@ -103,12 +106,13 @@ def display_help():
103106
print(_("usage: conjuguer [--debug] [--help|-?] [--locale LANG] [--version]"), file=sys.stderr)
104107
print(
105108
" "
106-
+ _("[-c|--columns NUMBER] [-d|--dictionary PATH] [-n|--nocolor]"),
109+
+ _("[-c|--columns NUMBER] [-n|--nocolor] [-D|--DELA] [-A|--ABU]"),
107110
file=sys.stderr
108111
)
112+
print(" " + _("[-d|--dictionary PATH]"), file=sys.stderr)
109113
print(" " + _("[--] verb [...]"), file=sys.stderr)
110114
print(
111-
" " + _("---------------- -----------------------------------------------------"),
115+
" " + _("-------------------- -----------------------------------------------------"),
112116
file=sys.stderr
113117
)
114118
print(
@@ -117,6 +121,8 @@ def display_help():
117121
)
118122
print(" " + _("-d|--dictionary PATH Select a specific dictionary"), file=sys.stderr)
119123
print(" " + _("-n|--nocolor Disable color output"), file=sys.stderr)
124+
print(" " + _("-D|--DELA Enable DELA format output"), file=sys.stderr)
125+
print(" " + _("-A|--ABU Enable ABU format output"), file=sys.stderr)
120126
print(" " + _("--debug Enable debug mode"), file=sys.stderr)
121127
print(
122128
" " + _("--help|-? Print usage and this help message and exit"),
@@ -231,10 +237,12 @@ def process_command_line(program_name):
231237

232238
# option letters followed by : expect an argument
233239
# same for option strings followed by =
234-
character_options = "c:d:n?"
240+
character_options = "Ac:d:Dn?"
235241
string_options = [
242+
"ABU",
236243
"columns=",
237244
"debug",
245+
"DELA",
238246
"dictionary=",
239247
"help",
240248
"locale=",
@@ -253,7 +261,11 @@ def process_command_line(program_name):
253261

254262
for option, argument in options:
255263

256-
if option in ("-c", "--columns"):
264+
if option in ("-A", "--ABU"):
265+
parameters["ABU output"] = True
266+
parameters["DELA output"] = False
267+
268+
elif option in ("-c", "--columns"):
257269
try:
258270
parameters["Display columns"] = int(argument)
259271
except ValueError:
@@ -266,6 +278,10 @@ def process_command_line(program_name):
266278
elif option == "--debug":
267279
logging.disable(logging.NOTSET)
268280

281+
elif option in ("-D", "--DELA"):
282+
parameters["DELA output"] = True
283+
parameters["ABU output"] = False
284+
269285
elif option in ("-d", "--dictionary"):
270286
if os.path.isfile(argument):
271287
parameters["Dictionary path"] = argument
@@ -952,10 +968,85 @@ def print_verb_conjugation_even_columns(conjugation):
952968
print(text)
953969

954970

971+
################################################################################
972+
def add_inflection(inflected_list, key, value):
973+
""" """
974+
if key:
975+
if key in inflected_list.keys():
976+
inflected_list[key] += value
977+
else:
978+
inflected_list[key] = value
979+
980+
return inflected_list
981+
982+
983+
################################################################################
984+
def print_ABU_inflections(verb):
985+
"""Print a verb conjugations in ABU format"""
986+
inflected_verb = {}
987+
inflected_verb = add_inflection(inflected_verb, verb["Infinitif"]["Présent"], ":Inf")
988+
for plural in [["s", "+SG"], ["p", "+PL"]]:
989+
for person in [["1", "+P1"], ["2", "+P2"], ["3", "+P3"]]:
990+
inflected_verb = add_inflection(inflected_verb, verb["Indicatif"]["Présent"][plural[0]][person[0]], ":IPre" + plural[1] + person[1])
991+
inflected_verb = add_inflection(inflected_verb, verb["Indicatif"]["Imparfait"][plural[0]][person[0]], ":IImp" + plural[1] + person[1])
992+
inflected_verb = add_inflection(inflected_verb, verb["Indicatif"]["Passé simple"][plural[0]][person[0]], ":IPSim" + plural[1] + person[1])
993+
inflected_verb = add_inflection(inflected_verb, verb["Indicatif"]["Futur simple"][plural[0]][person[0]], ":IFut" + plural[1] + person[1])
994+
inflected_verb = add_inflection(inflected_verb, verb["Conditionnel"]["Présent"][plural[0]][person[0]], ":CPre" + plural[1] + person[1])
995+
inflected_verb = add_inflection(inflected_verb, verb["Subjonctif"]["Présent"][plural[0]][person[0]], ":SPre" + plural[1] + person[1])
996+
inflected_verb = add_inflection(inflected_verb, verb["Subjonctif"]["Imparfait"][plural[0]][person[0]], ":SImp" + plural[1] + person[1])
997+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Présent"], ":PPre")
998+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Passé"]["s"]["m"], ":PPas+Mas+SG")
999+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Passé"]["s"]["f"], ":PPas+Fem+SG")
1000+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Passé"]["p"]["m"], ":PPas+Mas+PL")
1001+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Passé"]["p"]["f"], ":PPas+Fem+PL")
1002+
inflected_verb = add_inflection(inflected_verb, verb["Impératif"]["Présent"]["s"]["2"], ":ImPre+SG+P2")
1003+
inflected_verb = add_inflection(inflected_verb, verb["Impératif"]["Présent"]["p"]["1"], ":ImPre+PL+P1")
1004+
inflected_verb = add_inflection(inflected_verb, verb["Impératif"]["Présent"]["p"]["2"], ":ImPre+PL+P2")
1005+
inflected_verb = collections.OrderedDict(sorted(inflected_verb.items()))
1006+
1007+
for key in inflected_verb.keys():
1008+
print("{} {} Ver{}".format(key, verb["Infinitif"]["Présent"], inflected_verb[key]))
1009+
1010+
1011+
################################################################################
1012+
def print_DELA_inflections(verb):
1013+
"""Print a verb conjugations in DELA format"""
1014+
inflected_verb = {}
1015+
inflected_verb = add_inflection(inflected_verb, verb["Infinitif"]["Présent"], ":W")
1016+
for plural in ["s", "p"]:
1017+
for person in ["1", "2", "3"]:
1018+
inflected_verb = add_inflection(inflected_verb, verb["Indicatif"]["Présent"][plural][person], ":P" + person + plural)
1019+
inflected_verb = add_inflection(inflected_verb, verb["Indicatif"]["Imparfait"][plural][person], ":I" + person + plural)
1020+
inflected_verb = add_inflection(inflected_verb, verb["Indicatif"]["Passé simple"][plural][person], ":J" + person + plural)
1021+
inflected_verb = add_inflection(inflected_verb, verb["Indicatif"]["Futur simple"][plural][person], ":F" + person + plural)
1022+
inflected_verb = add_inflection(inflected_verb, verb["Conditionnel"]["Présent"][plural][person], ":C" + person + plural)
1023+
inflected_verb = add_inflection(inflected_verb, verb["Subjonctif"]["Présent"][plural][person], ":S" + person + plural)
1024+
inflected_verb = add_inflection(inflected_verb, verb["Subjonctif"]["Imparfait"][plural][person], ":T" + person + plural)
1025+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Présent"], ":G")
1026+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Passé"]["s"]["m"], ":Kms")
1027+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Passé"]["s"]["f"], ":Kfs")
1028+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Passé"]["p"]["m"], ":Kmp")
1029+
inflected_verb = add_inflection(inflected_verb, verb["Participe"]["Passé"]["p"]["f"], ":Kfp")
1030+
inflected_verb = add_inflection(inflected_verb, verb["Impératif"]["Présent"]["s"]["2"], ":Y2s")
1031+
inflected_verb = add_inflection(inflected_verb, verb["Impératif"]["Présent"]["p"]["1"], ":Y1p")
1032+
inflected_verb = add_inflection(inflected_verb, verb["Impératif"]["Présent"]["p"]["2"], ":Y2p")
1033+
inflected_verb = collections.OrderedDict(sorted(inflected_verb.items()))
1034+
1035+
for key in inflected_verb.keys():
1036+
if key == verb["Infinitif"]["Présent"]:
1037+
print("{},.V{}".format(key, inflected_verb[key]))
1038+
else:
1039+
print("{},{}.V{}".format(key, verb["Infinitif"]["Présent"], inflected_verb[key]))
1040+
1041+
9551042
################################################################################
9561043
def print_verb_conjugation(verb):
957-
"""Print a 1, 2 or 4 columns verb conjugation"""
958-
if parameters["Display columns"] == 1:
1044+
"""Print a verb conjugations in different output formats"""
1045+
if parameters["ABU output"]:
1046+
print_ABU_inflections(verb)
1047+
elif parameters["DELA output"]:
1048+
print_DELA_inflections(verb)
1049+
elif parameters["Display columns"] == 1:
9591050
print_verb_conjugation_odd_columns(verb)
9601051
else:
9611052
print_verb_conjugation_even_columns(verb)
@@ -986,17 +1077,23 @@ def main():
9861077
for argument in arguments:
9871078
conjugations = select_verb_from_verbs(argument, verbs)
9881079
if conjugations:
1080+
verb = None
1081+
verb2 = None
1082+
9891083
if argument in etre_aux:
9901084
verb = conjuguer(argument, conjugations, "être")
991-
print_verb_conjugation(verb)
9921085
elif argument in both_aux:
993-
verb1 = conjuguer(argument, conjugations, "être")
994-
print_verb_conjugation(verb1)
1086+
verb = conjuguer(argument, conjugations, "être")
9951087
verb2 = conjuguer(argument, conjugations, "avoir")
996-
print_verb_conjugation(verb2)
9971088
else:
9981089
verb = conjuguer(argument, conjugations, "avoir")
999-
print_verb_conjugation(verb)
1090+
1091+
print_verb_conjugation(verb)
1092+
if argument in both_aux \
1093+
and not parameters["ABU output"] \
1094+
and not parameters["DELA output"]:
1095+
print_verb_conjugation(verb2)
1096+
10001097
else:
10011098
logging.error("%s " + _("is not in the dictionary used"), argument)
10021099
pattern, group, model = analyze_verb(argument)

0 commit comments

Comments
 (0)