mirror of
				https://github.com/Thor77/TeamspeakStats.git
				synced 2025-11-03 15:22:45 -05:00 
			
		
		
		
	Add cached_files-property to Cache
to easily access store-keys without unwanted 'version'-key
This commit is contained in:
		
							parent
							
								
									f6e3f9566b
								
							
						
					
					
						commit
						9d9a7cf2b5
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -95,6 +95,12 @@ class Cache(MutableMapping):
 | 
			
		|||
            return True
 | 
			
		||||
        return _calculate_hash(path) != self.store[path].hash
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def cached_files(self):
 | 
			
		||||
        store_keys = list(self.store.keys())
 | 
			
		||||
        store_keys.remove('version')
 | 
			
		||||
        return store_keys
 | 
			
		||||
 | 
			
		||||
    def __setitem__(self, path, events):
 | 
			
		||||
        self.store[path] = CachedLog(path, _calculate_hash(path), list(events))
 | 
			
		||||
        self.store['version'] += 1
 | 
			
		||||
| 
						 | 
				
			
			@ -106,7 +112,7 @@ class Cache(MutableMapping):
 | 
			
		|||
        del self.store[path]
 | 
			
		||||
 | 
			
		||||
    def __iter__(self):
 | 
			
		||||
        return iter(self.store.keys() - ['version'])
 | 
			
		||||
        return iter(self.cached_files)
 | 
			
		||||
 | 
			
		||||
    def __len__(self):
 | 
			
		||||
        return len(self.store.keys() - ['version'])
 | 
			
		||||
        return len(self.cached_files)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue