mirror of
				https://github.com/derrod/legendary.git
				synced 2025-11-04 10:24:49 +00:00 
			
		
		
		
	[models] Add get_chunk_by_path to CDL
This commit is contained in:
		
							parent
							
								
									d94d07a26b
								
							
						
					
					
						commit
						3257b869e2
					
				| 
						 | 
				
			
			@ -277,6 +277,18 @@ class CDL:
 | 
			
		|||
        self._manifest_version = 17
 | 
			
		||||
        self._guid_map = None
 | 
			
		||||
        self._guid_int_map = None
 | 
			
		||||
        self._path_map = None
 | 
			
		||||
 | 
			
		||||
    def get_chunk_by_path(self, path):
 | 
			
		||||
        if not self._path_map:
 | 
			
		||||
            self._path_map = dict()
 | 
			
		||||
            for index, chunk in enumerate(self.elements):
 | 
			
		||||
                self._path_map[chunk.path] = index
 | 
			
		||||
 | 
			
		||||
        index = self._path_map.get(path, None)
 | 
			
		||||
        if index is None:
 | 
			
		||||
            raise ValueError(f'Invalid path! "{path}"')
 | 
			
		||||
        return self.elements[index]
 | 
			
		||||
 | 
			
		||||
    def get_chunk_by_guid(self, guid):
 | 
			
		||||
        """
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue