88import compiler_admin .services .files as files
99
1010# input CSV columns needed for conversion
11- INPUT_COLUMNS = ["Date" , "Client" , "Project" , "Notes" , "Hours" , "First name" , "Last name" ]
11+ HARVEST_COLUMNS = ["Date" , "Client" , "Project" , "Notes" , "Hours" , "First name" , "Last name" ]
1212
1313# default output CSV columns
14- OUTPUT_COLUMNS = ["Email" , "Start date" , "Start time" , "Duration" , "Project" , "Task" , "Client" , "Billable" , "Description" ]
14+ TOGGL_COLUMNS = ["Email" , "Start date" , "Start time" , "Duration" , "Project" , "Task" , "Client" , "Billable" , "Description" ]
1515
1616
1717def _calc_start_time (group : pd .DataFrame ):
@@ -33,8 +33,9 @@ def _toggl_client_name():
3333def convert_to_toggl (
3434 source_path : str | TextIO = sys .stdin ,
3535 output_path : str | TextIO = sys .stdout ,
36+ output_cols : list [str ] = TOGGL_COLUMNS ,
3637 client_name : str = None ,
37- output_cols : list [ str ] = OUTPUT_COLUMNS ,
38+ ** kwargs ,
3839):
3940 """Convert Harvest formatted entries in source_path to equivalent Toggl formatted entries.
4041
@@ -52,7 +53,7 @@ def convert_to_toggl(
5253 client_name = _toggl_client_name ()
5354
5455 # read CSV file, parsing dates
55- source = files .read_csv (source_path , usecols = INPUT_COLUMNS , parse_dates = ["Date" ], cache_dates = True )
56+ source = files .read_csv (source_path , usecols = HARVEST_COLUMNS , parse_dates = ["Date" ], cache_dates = True )
5657
5758 # rename columns that can be imported as-is
5859 source .rename (columns = {"Project" : "Task" , "Notes" : "Description" , "Date" : "Start date" }, inplace = True )
@@ -89,3 +90,6 @@ def convert_to_toggl(
8990 output_data .sort_values (["Start date" , "Start time" , "Email" ], inplace = True )
9091
9192 files .write_csv (output_path , output_data , output_cols )
93+
94+
95+ CONVERTERS = {"toggl" : convert_to_toggl }
0 commit comments