Optimisation lors du traitement des tags : gain x10 en temps d'exécution
This commit is contained in:
		
							
								
								
									
										20
									
								
								exv.py
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								exv.py
									
									
									
									
									
								
							@@ -78,15 +78,21 @@ def extractor(input_files, start, end, recursive, extensions):
 | 
				
			|||||||
        if not isfile(input_file):
 | 
					        if not isfile(input_file):
 | 
				
			||||||
            raise ValueError("{} doesn't exist here.".format(input_file))
 | 
					            raise ValueError("{} doesn't exist here.".format(input_file))
 | 
				
			||||||
        exif_dict.update({'file': input_file})
 | 
					        exif_dict.update({'file': input_file})
 | 
				
			||||||
        for extracted in usefull_exif:
 | 
					        cmd = ["exiv2", "-Ptk", input_file]
 | 
				
			||||||
            cmd = ["exiv2", "-g", extracted, "-Pt", input_file]
 | 
					 | 
				
			||||||
        with Popen(cmd, stdout=PIPE) as extracted_data:
 | 
					        with Popen(cmd, stdout=PIPE) as extracted_data:
 | 
				
			||||||
            extracted_data = extracted_data.stdout.read().decode()
 | 
					            extracted_data = extracted_data.stdout.read().decode()
 | 
				
			||||||
                if extracted_data:
 | 
					            for line in extracted_data.splitlines():
 | 
				
			||||||
                    extracted_data = extracted_data.splitlines()[0]
 | 
					                for exif in usefull_exif:
 | 
				
			||||||
                    exif_dict.update({extracted.split(".")[-1]: extracted_data})
 | 
					                    if exif in line.split()[0]:
 | 
				
			||||||
                else:
 | 
					                        exif_dict.update(
 | 
				
			||||||
                    exif_dict.update({extracted.split(".")[-1]: None})
 | 
					                                {
 | 
				
			||||||
 | 
					                                    line.split()[0].split(".")[-1]:
 | 
				
			||||||
 | 
					                                    " ".join(line.split()[1:])
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                )
 | 
				
			||||||
 | 
					        for exif in usefull_exif:
 | 
				
			||||||
 | 
					            if exif.split(".")[-1] not in exif_dict:
 | 
				
			||||||
 | 
					                exif_dict.update({exif.split(".")[-1]: None})
 | 
				
			||||||
        if exif_dict['FocalLength']:
 | 
					        if exif_dict['FocalLength']:
 | 
				
			||||||
            exif_dict['FocalLength'] = float(
 | 
					            exif_dict['FocalLength'] = float(
 | 
				
			||||||
                exif_dict['FocalLength'].replace(" mm", ""))
 | 
					                exif_dict['FocalLength'].replace(" mm", ""))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user