-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
20 lines (17 loc) · 951 Bytes
/
main.py
File metadata and controls
20 lines (17 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from argparse import ArgumentParser, FileType
import os
import export_paystubs_to_csv
EXPORT_PAYSTUBS_TO_CSV="export_paystubs_to_csv"
if __name__ == "__main__":
# Global args parser
parser = ArgumentParser(description="Scripts for personal workflows written in Python")
subparsers = parser.add_subparsers(dest="command", help="sub-command")
# export_paystubs_to_csv
export_paystubs_to_csv_parser = subparsers.add_parser(EXPORT_PAYSTUBS_TO_CSV, help="Export data parsed from paystub PDFs to CSV")
export_paystubs_to_csv_parser.add_argument("--paystubs", help="PDF with Paystubs to parse", required=True, type=FileType("r"))
args = parser.parse_args()
if args.command == EXPORT_PAYSTUBS_TO_CSV:
file_name, file_extension = os.path.splitext(args.paystubs.name)
if file_extension != ".pdf":
raise Exception("File passed to --paystubs must be a PDF")
export_paystubs_to_csv.main(args)