55
66from NAF import NAF_TO_DNI , validate_parse_naf
77from custom_except import *
8- from defines import NAF_DATA_PATH
8+ from defines import NAF_DATA_PATH , DocType
9+
10+
11+ def get_compact_init ():
12+ return {DocType .SALARY : False , DocType .PROOFS : False , DocType .CONTRACT : False , DocType .RNT : False }
913
1014
1115def parse_date (value , formatting = "%Y_%m" ):
@@ -32,6 +36,18 @@ def parse_naf(value):
3236 raise ArgumentNafNotPresent ("NAF is not valid" + e .__str__ ())
3337
3438
39+ def parse_compact (value ):
40+ to_compact = get_compact_init ()
41+ try :
42+ for s in value .split ("," ):
43+ doc_type = DocType .from_string (s )
44+ to_compact [doc_type ] = True
45+ return to_compact
46+ except ValueError as e :
47+ print (f"Error: { e } " )
48+ exit (1 )
49+
50+
3551def parse_arguments (valid_nafs ):
3652 """Parse and validate command-line arguments"""
3753 parser = argparse .ArgumentParser (description = "Process NAF and date range." )
@@ -42,6 +58,10 @@ def parse_arguments(valid_nafs):
4258 parser .add_argument ("-e" , "--end" , type = parse_date , required = True , help = "End date (YYYY-MM)" )
4359 parser .add_argument ("-a" , "--author" , type = parse_author , required = True , help = "author's email doing request" )
4460
61+ parser .add_argument ("-c" , "--compact" , type = parse_compact , required = False , default = get_compact_init () , help = "Comma separated list of values "
62+ "that indicate "
63+ "which documents need to be merged in one signle PDF in the output. Possible values are: " + "," .join ([dt .value .__str__ () for dt in DocType ]))
64+
4565 args = parser .parse_args ()
4666
4767 return args
0 commit comments