File tree 2 files changed +49
-9
lines changed
2 files changed +49
-9
lines changed Original file line number Diff line number Diff line change 7
7
8
8
# file = "Data/portfolio.csv"
9
9
10
- def portfolio_cost (file ):
10
+ def portfolio_cost (filename ):
11
11
portfolio = report .read_portfolio (filename )
12
- return sum ([s ['shares' ]* s ['price' ] for s in portfolio ])
12
+ return sum ([s ['shares' ] * s ['price' ] for s in portfolio ])
13
+
14
+ def main (args ):
15
+ if len (args ) != 2 :
16
+ raise SystemExit ('Usage: %s portfoliofile' % args [0 ])
17
+ filename = args [1 ]
18
+ print ('Total cost:' , portfolio_cost (filename ))
19
+
20
+ if __name__ == '__main__' :
21
+ main (sys .argv )
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
13
50
14
- if len (sys .argv ) == 2 :
15
- filename = sys .argv [1 ]
16
- else :
17
- filename = input ("Enter a filename: " )
18
51
19
- cost = portfolio_cost (filename )
20
- print (f"Total cost: { cost } " )
Original file line number Diff line number Diff line change @@ -36,4 +36,13 @@ def portfolio_report(portfoliofile, pricefile):
36
36
report = make_report (portfolio , prices )
37
37
print_report (report )
38
38
39
- portfolio_report ('Data/portfoliodate.csv' , 'Data/prices.csv' )
39
+ #portfolio_report('Data/portfoliodate.csv', 'Data/prices.csv)
40
+
41
+ def main (args ):
42
+ if len (args ) != 3 :
43
+ raise SystemExit ("Usage: %s portfile pricefile" % args [0 ])
44
+ portfolio_report (args [1 ], args [2 ])
45
+
46
+ if __name__ == "__main__" :
47
+ import sys
48
+ main (sys .argv )
You can’t perform that action at this time.
0 commit comments