@@ -4266,7 +4266,7 @@ def __init__(
42664266 extensions = constances .DEFAULT_IMAGE_EXTENSIONS ,
42674267 annotation_status = "NotStarted" ,
42684268 from_s3_bucket = None ,
4269- exclude_file_patterns = constances .DEFAULT_FILE_EXCLUDE_PATTERNS ,
4269+ exclude_file_patterns : List [ str ] = constances .DEFAULT_FILE_EXCLUDE_PATTERNS ,
42704270 recursive_sub_folders : bool = False ,
42714271 image_quality_in_editor = None ,
42724272 ):
@@ -4286,6 +4286,10 @@ def __init__(
42864286 self ._from_s3_bucket = from_s3_bucket
42874287 self ._extensions = extensions
42884288 self ._recursive_sub_folders = recursive_sub_folders
4289+ if exclude_file_patterns :
4290+ list (exclude_file_patterns ).extend (
4291+ list (constances .DEFAULT_FILE_EXCLUDE_PATTERNS )
4292+ )
42894293 self ._exclude_file_patterns = exclude_file_patterns
42904294 self ._annotation_status = annotation_status
42914295
@@ -4302,12 +4306,19 @@ def exclude_file_patterns(self):
43024306 return self ._exclude_file_patterns
43034307
43044308 def validate_annotation_status (self ):
4305- if self ._annotation_status and self ._annotation_status .lower () not in constances .AnnotationStatus .values ():
4309+ if (
4310+ self ._annotation_status
4311+ and self ._annotation_status .lower ()
4312+ not in constances .AnnotationStatus .values ()
4313+ ):
43064314 raise AppValidationException ("Invalid annotations status" )
43074315
43084316 def validate_extensions (self ):
43094317 if self ._extensions and not all (
4310- [extension in constances .DEFAULT_IMAGE_EXTENSIONS for extension in self ._extensions ]
4318+ [
4319+ extension in constances .DEFAULT_IMAGE_EXTENSIONS
4320+ for extension in self ._extensions
4321+ ]
43114322 ):
43124323 raise AppValidationException ("" )
43134324
@@ -4420,14 +4431,16 @@ def paths(self):
44204431 paths .append (key )
44214432 break
44224433
4423- paths = [str (path ) for path in paths ]
4424- return [
4425- path
4426- for path in paths
4427- if "___objects" not in path
4428- and "___fuse" not in path
4429- and "___pixel" not in path
4430- ]
4434+ data = []
4435+ for path in paths :
4436+ if all (
4437+ [
4438+ True if exclude_pattern not in str (path ) else False
4439+ for exclude_pattern in self .exclude_file_patterns
4440+ ]
4441+ ):
4442+ data .append (str (path ))
4443+ return data
44314444
44324445 @property
44334446 def images_to_upload (self ):
@@ -4490,8 +4503,9 @@ def execute(self):
44904503 annotation_status = self ._annotation_status ,
44914504 ).execute ()
44924505
4493- attachments , duplications = response .data
4506+ attachments , attach_duplications = response .data
44944507 uploaded .extend (attachments )
4508+ duplications .extend (attach_duplications )
44954509 uploaded = [image ["name" ] for image in uploaded ]
44964510 failed_images = [image .split ("/" )[- 1 ] for image in failed_images ]
44974511
@@ -4517,17 +4531,12 @@ def __init__(
45174531
45184532 def execute (self ) -> Response :
45194533
4520- if self ._folder .name == "root" and not self ._image_names :
4521- response = self ._backend_service .delete_image_annotations (
4522- project_id = self ._project .uuid , team_id = self ._project .team_id , image_names = self ._image_names
4523- )
4524- else :
4525- response = self ._backend_service .delete_image_annotations (
4526- project_id = self ._project .uuid ,
4527- team_id = self ._project .team_id ,
4528- folder_id = self ._folder .uuid ,
4529- image_names = self ._image_names ,
4530- )
4534+ response = self ._backend_service .delete_image_annotations (
4535+ project_id = self ._project .uuid ,
4536+ team_id = self ._project .team_id ,
4537+ folder_id = self ._folder .uuid ,
4538+ image_names = self ._image_names ,
4539+ )
45314540
45324541 if response :
45334542 timeout_start = time .time ()
0 commit comments