Skip to content

Commit 74cf2b4

Browse files
committed
Added command line arguments for initial years
1 parent a76ea3a commit 74cf2b4

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ YearCalculator is a part of [OpenNumismat](http://opennumismat.github.io/) proje
1010
[Latest version for Windows 10 and later](https://github.com/OpenNumismat/YearCalculator/releases/latest)
1111
[Version 0.1 for Windows XP and later](https://github.com/OpenNumismat/YearCalculator/releases/download/0.1/YearCalculator.zip)
1212

13+
#### Usage
14+
YearCalculator.exe [-h] [-l {en,bg,de,es,pt,ru,sl,uk}] [-g GREGORIAN] [-n NATIVE]
15+
[-c {hebrew,islamic,iranian,japanese,roman,nepal,thai,burmese}]
16+
17+
options:
18+
-h, --help show this help message and exit
19+
-l {en,bg,de,es,pt,ru,sl,uk}, --lang {en,bg,de,es,pt,ru,sl,uk}
20+
UI language. If not specified, the system language is used
21+
-g GREGORIAN, --gregorian GREGORIAN
22+
Initial gregorian year
23+
-n NATIVE, --native NATIVE
24+
Initial year in native calendar
25+
-c {hebrew,islamic,iranian,japanese,roman,nepal,thai,burmese}, --calendar {hebrew,islamic,iranian,japanese,roman,nepal,thai,burmese}
26+
1327
#### For run from source code
1428
pip3 install -r requirements.txt
1529
python3 src/run.py

src/YearCalculator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class YearCalculatorDialog(QDialog):
1111
class CALENDARS():
1212
HEBREW = 0
1313
ISLAMIC = 1
14-
SOLAR_HIJRI = 2
15-
JAPAN = 3
14+
IRANIAN = 2
15+
JAPANESE = 3
1616
ROMAN = 4
1717
NEPAL = 5
1818
THAI = 6

src/run.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ def main():
1313
"-l", "--lang", choices=('en', 'bg', 'de', 'es', 'pt', 'ru', 'sl', 'uk'),
1414
help="UI language. If not specified, the system language is used"
1515
)
16+
parser.add_argument(
17+
"-g", "--gregorian", type=int,
18+
help="Initial gregorian year"
19+
)
20+
parser.add_argument(
21+
"-n", "--native",
22+
help="Initial year in native calendar"
23+
)
24+
parser.add_argument(
25+
"-c", "--calendar",
26+
choices=('hebrew', 'islamic', 'iranian', 'japanese', 'roman', 'nepal', 'thai', 'burmese')
27+
)
1628

1729
args = parser.parse_args()
1830

@@ -30,7 +42,36 @@ def main():
3042
if translator.load(locale, 'qtbase', '_', path):
3143
app.installTranslator(translator)
3244

33-
dlg = YearCalculatorDialog('2022', '')
45+
if args.gregorian:
46+
gregorian_year = str(args.gregorian)
47+
else:
48+
gregorian_year = ''
49+
50+
if args.native:
51+
native_year = args.native
52+
else:
53+
native_year = ''
54+
55+
if args.calendar == 'hebrew':
56+
calendar_type = YearCalculatorDialog.CALENDARS.HEBREW
57+
elif args.calendar == 'islamic':
58+
calendar_type = YearCalculatorDialog.CALENDARS.ISLAMIC
59+
elif args.calendar == 'iranian':
60+
calendar_type = YearCalculatorDialog.CALENDARS.IRANIAN
61+
elif args.calendar == 'japanese':
62+
calendar_type = YearCalculatorDialog.CALENDARS.JAPANESE
63+
elif args.calendar == 'roman':
64+
calendar_type = YearCalculatorDialog.CALENDARS.ROMAN
65+
elif args.calendar == 'nepal':
66+
calendar_type = YearCalculatorDialog.CALENDARS.NEPAL
67+
elif args.calendar == 'thai':
68+
calendar_type = YearCalculatorDialog.CALENDARS.THAI
69+
elif args.calendar == 'burmese':
70+
calendar_type = YearCalculatorDialog.CALENDARS.BURMESE
71+
else:
72+
calendar_type = YearCalculatorDialog.CALENDARS.DEFAULT
73+
74+
dlg = YearCalculatorDialog(gregorian_year, native_year, calendar_type)
3475
if dlg.exec() == QDialog.Accepted:
3576
print(dlg.year(), '=', dlg.nativeYear())
3677

0 commit comments

Comments
 (0)