@@ -176,7 +176,7 @@ def upload_files(
176176 upload_type : FileTransferType ,
177177 project_path : str ,
178178 filter_glob : str ,
179- exit_on_error : bool = False ,
179+ throw_on_error : bool = False ,
180180 show_progress : bool = False ,
181181 job_id : str = "" ,
182182 ) -> List [Dict ]:
@@ -206,7 +206,7 @@ def upload_files(
206206 file ["status" ] = UploadStatus .FAILED
207207 file ["error" ] = err
208208
209- if exit_on_error :
209+ if throw_on_error :
210210 raise err
211211 else :
212212 continue
@@ -262,7 +262,7 @@ def download_project(
262262 project_id : str ,
263263 local_dir : str ,
264264 filter_glob : str = None ,
265- exit_on_error : bool = False ,
265+ throw_on_error : bool = False ,
266266 show_progress : bool = False ,
267267 ) -> List [Dict ]:
268268 """Download the specified project files into the destination dir.
@@ -281,7 +281,7 @@ def download_project(
281281 FileTransferType .PROJECT ,
282282 local_dir ,
283283 filter_glob ,
284- exit_on_error ,
284+ throw_on_error ,
285285 show_progress ,
286286 )
287287
@@ -327,9 +327,23 @@ def delete_files(
327327 self ,
328328 project_id : str ,
329329 glob_patterns : List [str ],
330- continue_on_error : bool = False ,
330+ throw_on_error : bool = False ,
331331 finished_cb : Callable = None ,
332332 ) -> Dict [str , Dict [str , Any ]]:
333+ """Delete project files.
334+
335+ Args:
336+ project_id (str): Project id
337+ glob_patterns (List[str]): Delete only files matching one the glob patterns.
338+ throw_on_error (bool, optional): Throw if delete error occurres. Defaults to False.
339+ finished_cb (Callable, optional): Deprecated. Defaults to None.
340+
341+ Raises:
342+ QFieldCloudException: if throw_on_error is True, throw an error if a download request fails.
343+
344+ Returns:
345+ Dict[str, Dict[str, Any]]: Deleted files by glob pattern.
346+ """
333347 project_files = self .list_files (project_id )
334348 glob_results = {}
335349 self ._log (f"Project '{ project_id } ' has { len (project_files )} file(s)." )
@@ -375,7 +389,7 @@ def delete_files(
375389 f'File "{ file ["name" ]} " failed to delete:\n { file ["error" ]} '
376390 )
377391
378- if continue_on_error :
392+ if throw_on_error :
379393 continue
380394 else :
381395 raise err
@@ -411,7 +425,7 @@ def package_download(
411425 project_id : str ,
412426 local_dir : str ,
413427 filter_glob : str = None ,
414- exit_on_error : bool = False ,
428+ throw_on_error : bool = False ,
415429 show_progress : bool = False ,
416430 ) -> List [Dict ]:
417431 """Download the specified project packaged files into the destination dir.
@@ -436,7 +450,7 @@ def package_download(
436450 FileTransferType .PACKAGE ,
437451 local_dir ,
438452 filter_glob ,
439- exit_on_error ,
453+ throw_on_error ,
440454 show_progress ,
441455 )
442456
@@ -447,9 +461,26 @@ def download_files(
447461 download_type : FileTransferType ,
448462 local_dir : str ,
449463 filter_glob : str = None ,
450- exit_on_error : bool = False ,
464+ throw_on_error : bool = False ,
451465 show_progress : bool = False ,
452466 ) -> List [Dict ]:
467+ """Download project files.
468+
469+ Args:
470+ files (List[Dict]): A list of file dicts, specifying which files to download.
471+ project_id (str): Project id
472+ download_type (FileTransferType): File transfer type which specifies what should be the download url.
473+ local_dir (str): Local destination directory
474+ filter_glob (str, optional): Download only files matching the glob pattern. If None download all. Defaults to None.
475+ throw_on_error (bool, optional): Throw if download error occurres. Defaults to False.
476+ show_progress (bool, optional): Show progress bar in the console. Defaults to False.
477+
478+ Raises:
479+ QFieldCloudException: if throw_on_error is True, throw an error if a download request fails.
480+
481+ Returns:
482+ List[Dict]: A list of file dicts.
483+ """
453484 if not filter_glob :
454485 filter_glob = "*"
455486
@@ -482,7 +513,7 @@ def download_files(
482513 file ["status" ] = DownloadStatus .FAILED
483514 file ["error" ] = err
484515
485- if exit_on_error :
516+ if throw_on_error :
486517 raise err
487518 else :
488519 continue
@@ -497,6 +528,21 @@ def download_file(
497528 remote_filename : Path ,
498529 show_progress : bool ,
499530 ) -> requests .Response :
531+ """Download a single project file.
532+
533+ Args:
534+ project_id (str): Project id
535+ download_type (FileTransferType): File transfer type which specifies what should be the download URL
536+ local_filename (Path): Local filename
537+ remote_filename (Path): Remote filename
538+ show_progress (bool): Show progressbar in the console
539+
540+ Raises:
541+ NotImplementedError: Raised if unknown `download_type` is passed
542+
543+ Returns:
544+ requests.Response: the response object
545+ """
500546 if download_type == FileTransferType .PROJECT :
501547 url = f"files/{ project_id } /{ remote_filename } "
502548 elif download_type == FileTransferType .PACKAGE :
@@ -532,18 +578,20 @@ def download_file(
532578
533579 return resp
534580
535- def get_files_list (
536- self , project_path : str , filter_glob : str
537- ) -> List [Dict [str , Any ]]:
581+ def get_files_list (self , root_path : str , filter_glob : str ) -> List [Dict [str , Any ]]:
582+ """
583+ Returns a list of dicts with information about local files. Usually used before uploading files.
584+ NOTE: files and dirs starting with leading zero in the root directory will be ignored.
585+ """
538586 if not filter_glob :
539587 filter_glob = "*"
540588
541589 files : List [Dict [str , Any ]] = []
542- for path in Path (project_path ).rglob (filter_glob ):
590+ for path in Path (root_path ).rglob (filter_glob ):
543591 if not path .is_file ():
544592 continue
545593
546- if str (path .relative_to (project_path )).startswith (".qfieldsync " ):
594+ if str (path .relative_to (root_path )).startswith ("." ):
547595 continue
548596
549597 files .append (
0 commit comments