File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 33from csv2vcard .parse_csv import parse_csv
44
55
6- def csv2vcard (csv_filename : str , csv_delimeter : str ):
6+ def csv2vcard (csv_filename : str , csv_delimeter : str , single_file = True ):
77 """
88 Main function
99 """
1010 check_export ()
1111
1212 for c in parse_csv (csv_filename , csv_delimeter ):
1313 vcard = create_vcard (c )
14- export_vcard (vcard )
14+ export_vcard (vcard , single_file )
1515
1616
1717def test_csv2vcard ():
@@ -29,4 +29,4 @@ def test_csv2vcard():
2929 check_export ()
3030 vcard = create_vcard (mock_contacts [0 ])
3131 print (vcard )
32- export_vcard (vcard )
32+ export_vcard (vcard , single_file = False )
Original file line number Diff line number Diff line change 11import os
22
3- def export_vcard (vc_final ):
3+ def export_vcard (vc_final , single_file ):
44 """
55 Exporting a vCard to /export/
66 """
77 try :
8- with open (f"export/{ vc_final ['filename' ]} " , "w" ) as f :
8+ file_name = f"export/{ vc_final ['filename' ]} " if not single_file else f"export/final_export.vcf"
9+ with open (file_name , "a" ) as f :
910 f .write (vc_final ['output' ])
1011 f .close ()
1112 print (f"Created vCard 3.0 for { vc_final ['name' ]} ." )
You can’t perform that action at this time.
0 commit comments