@@ -130,11 +130,6 @@ def detailed_time_entries(self, start_date: datetime, end_date: datetime, **kwar
130130 return response
131131
132132
133- def _harvest_client_name ():
134- """Gets the value of the HARVEST_CLIENT_NAME env var."""
135- return os .environ .get ("HARVEST_CLIENT_NAME" )
136-
137-
138133def _get_info (obj : dict , key : str , env_key : str ):
139134 """Read key from obj, populating obj once from a file path at env_key."""
140135 if obj == {}:
@@ -145,19 +140,6 @@ def _get_info(obj: dict, key: str, env_key: str):
145140 return obj .get (key )
146141
147142
148- def _toggl_api_token ():
149- """Gets the value of the TOGGL_API_TOKEN env var."""
150- return os .environ .get ("TOGGL_API_TOKEN" )
151-
152-
153- def _toggl_client_id ():
154- """Gets the value of the TOGGL_CLIENT_ID env var."""
155- client_id = os .environ .get ("TOGGL_CLIENT_ID" )
156- if client_id :
157- return int (client_id )
158- return None
159-
160-
161143def _toggl_project_info (project : str ):
162144 """Return the cached project for the given project key."""
163145 return _get_info (PROJECT_INFO , project , "TOGGL_PROJECT_INFO" )
@@ -168,11 +150,6 @@ def _toggl_user_info(email: str):
168150 return _get_info (USER_INFO , email , "TOGGL_USER_INFO" )
169151
170152
171- def _toggl_workspace ():
172- """Gets the value of the TOGGL_WORKSPACE_ID env var."""
173- return os .environ .get ("TOGGL_WORKSPACE_ID" )
174-
175-
176153def _get_first_name (email : str ) -> str :
177154 """Get cached first name or derive from email."""
178155 user = _toggl_user_info (email )
@@ -228,7 +205,7 @@ def convert_to_harvest(
228205 None. Either prints the resulting CSV data or writes to output_path.
229206 """
230207 if client_name is None :
231- client_name = _harvest_client_name ( )
208+ client_name = os . environ . get ( "HARVEST_CLIENT_NAME" )
232209
233210 # read CSV file, parsing dates and times
234211 source = files .read_csv (source_path , usecols = INPUT_COLUMNS , parse_dates = ["Start date" ], cache_dates = True )
@@ -279,11 +256,14 @@ def download_time_entries(
279256 Returns:
280257 None. Either prints the resulting CSV data or writes to output_path.
281258 """
282- if ("client_ids" not in kwargs or not kwargs ["client_ids" ]) and isinstance (_toggl_client_id (), int ):
283- kwargs ["client_ids" ] = [_toggl_client_id ()]
284-
285- token = _toggl_api_token ()
286- workspace = _toggl_workspace ()
259+ env_client_id = os .environ .get ("TOGGL_CLIENT_ID" )
260+ if env_client_id :
261+ env_client_id = int (env_client_id )
262+ if ("client_ids" not in kwargs or not kwargs ["client_ids" ]) and isinstance (env_client_id , int ):
263+ kwargs ["client_ids" ] = [env_client_id ]
264+
265+ token = os .environ .get ("TOGGL_API_TOKEN" )
266+ workspace = os .environ .get ("TOGGL_WORKSPACE_ID" )
287267 toggl = Toggl (token , workspace )
288268
289269 response = toggl .detailed_time_entries (start_date , end_date , ** kwargs )
0 commit comments