5
5
import logging
6
6
from pprint import pformat
7
7
8
+ from freezegun import freeze_time
9
+
8
10
from . import const , utils
9
11
from .wamas2ubl import wamas2dict
10
12
11
13
_logger = logging .getLogger ("wamas2wamas" )
12
14
13
15
14
- def simulate_response (dict_wamas_in ):
16
+ def simulate_response (dict_wamas_in , partial_qty = False ):
15
17
res = []
16
18
line_idx = 0
17
19
dict_parent_id = {}
@@ -27,24 +29,29 @@ def simulate_response(dict_wamas_in):
27
29
dict_parent_id = dict_parent_id ,
28
30
telegram_type_out = telegram_type_out ,
29
31
do_wamas2wamas = True ,
32
+ partial_qty = partial_qty ,
30
33
)
31
34
if line :
32
35
res .append (line )
33
36
return res
34
37
35
38
36
- def wamas2wamas (infile ):
39
+ def wamas2wamas (infile , partial_qty = False ):
37
40
data = wamas2dict (infile )
38
41
_logger .debug (pformat (data ))
39
- wamas_lines = simulate_response (data )
42
+ wamas_lines = simulate_response (data , partial_qty = partial_qty )
40
43
return "\n " .join (wamas_lines )
41
44
42
45
46
+ @freeze_time ("2023-12-20 09:11:16" )
43
47
def main ():
44
48
parser = argparse .ArgumentParser (
45
49
description = "Converts a wamas message into wamas response." ,
46
50
)
47
51
parser .add_argument ("-v" , "--verbose" , action = "store_true" , help = "enable debug log" )
52
+ parser .add_argument (
53
+ "-p" , "--partial" , action = "store_true" , help = "simulate partial quantity"
54
+ )
48
55
parser .add_argument (
49
56
"-o" , "--output" , dest = "outputfile" , help = "write result in this file"
50
57
)
@@ -53,7 +60,7 @@ def main():
53
60
if args .verbose :
54
61
logging .basicConfig (level = logging .DEBUG )
55
62
infile = utils .file_open (args .inputfile ).read ()
56
- res = wamas2wamas (infile )
63
+ res = wamas2wamas (infile , args . partial )
57
64
if args .outputfile :
58
65
fd = utils .file_open (args .outputfile , "w" )
59
66
fd .write (res )
0 commit comments