@@ -128,11 +128,6 @@ def detailed_time_entries(self, start_date: datetime, end_date: datetime, **kwar
128128 return response
129129
130130
131- def _harvest_client_name ():
132- """Gets the value of the HARVEST_CLIENT_NAME env var."""
133- return os .environ .get ("HARVEST_CLIENT_NAME" )
134-
135-
136131def _get_info (obj : dict , key : str , env_key : str ):
137132 """Read key from obj, populating obj once from a file path at env_key."""
138133 if obj == {}:
@@ -143,19 +138,6 @@ def _get_info(obj: dict, key: str, env_key: str):
143138 return obj .get (key )
144139
145140
146- def _toggl_api_token ():
147- """Gets the value of the TOGGL_API_TOKEN env var."""
148- return os .environ .get ("TOGGL_API_TOKEN" )
149-
150-
151- def _toggl_client_id ():
152- """Gets the value of the TOGGL_CLIENT_ID env var."""
153- client_id = os .environ .get ("TOGGL_CLIENT_ID" )
154- if client_id :
155- return int (client_id )
156- return None
157-
158-
159141def _toggl_project_info (project : str ):
160142 """Return the cached project for the given project key."""
161143 return _get_info (PROJECT_INFO , project , "TOGGL_PROJECT_INFO" )
@@ -166,11 +148,6 @@ def _toggl_user_info(email: str):
166148 return _get_info (USER_INFO , email , "TOGGL_USER_INFO" )
167149
168150
169- def _toggl_workspace ():
170- """Gets the value of the TOGGL_WORKSPACE_ID env var."""
171- return os .environ .get ("TOGGL_WORKSPACE_ID" )
172-
173-
174151def _get_first_name (email : str ) -> str :
175152 """Get cached first name or derive from email."""
176153 user = _toggl_user_info (email )
@@ -226,7 +203,7 @@ def convert_to_harvest(
226203 None. Either prints the resulting CSV data or writes to output_path.
227204 """
228205 if client_name is None :
229- client_name = _harvest_client_name ( )
206+ client_name = os . environ . get ( "HARVEST_CLIENT_NAME" )
230207
231208 # read CSV file, parsing dates and times
232209 source = files .read_csv (source_path , usecols = INPUT_COLUMNS , parse_dates = ["Start date" ], cache_dates = True )
@@ -277,11 +254,14 @@ def download_time_entries(
277254 Returns:
278255 None. Either prints the resulting CSV data or writes to output_path.
279256 """
280- if ("client_ids" not in kwargs or not kwargs ["client_ids" ]) and isinstance (_toggl_client_id (), int ):
281- kwargs ["client_ids" ] = [_toggl_client_id ()]
282-
283- token = _toggl_api_token ()
284- workspace = _toggl_workspace ()
257+ env_client_id = os .environ .get ("TOGGL_CLIENT_ID" )
258+ if env_client_id :
259+ env_client_id = int (env_client_id )
260+ if ("client_ids" not in kwargs or not kwargs ["client_ids" ]) and isinstance (env_client_id , int ):
261+ kwargs ["client_ids" ] = [env_client_id ]
262+
263+ token = os .environ .get ("TOGGL_API_TOKEN" )
264+ workspace = os .environ .get ("TOGGL_WORKSPACE_ID" )
285265 toggl = Toggl (token , workspace )
286266
287267 response = toggl .detailed_time_entries (start_date , end_date , ** kwargs )
0 commit comments