mirror of
				https://github.com/wting/autojump
				synced 2025-06-13 12:54:07 +00:00 
			
		
		
		
	python 2.4 compatibility
This commit is contained in:
		
							parent
							
								
									1da392bad3
								
							
						
					
					
						commit
						91c05b1f8c
					
				
							
								
								
									
										22
									
								
								autojump
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								autojump
									
									
									
									
									
								
							| @ -47,9 +47,10 @@ def match(path,pattern,path_dict,ignore_case=False,only_end=False): | |||||||
|         match_string = path |         match_string = path | ||||||
|     #import re |     #import re | ||||||
|     #if re.search(pattern,match_string),re.IGNORECASE if ignore_case else 0) is None: |     #if re.search(pattern,match_string),re.IGNORECASE if ignore_case else 0) is None: | ||||||
|     match=(match_string.lower().find(pattern.lower()) != -1)\ |     if ignore_case: | ||||||
|             if ignore_case\ |         match=(match_string.lower().find(pattern.lower()) != -1) | ||||||
|             else (match_string.find(pattern) != -1) |     else: | ||||||
|  |         match=(match_string.find(pattern) != -1) | ||||||
|     if not match: |     if not match: | ||||||
|         return False |         return False | ||||||
|     else:  |     else:  | ||||||
| @ -83,6 +84,16 @@ def forget(path_dict,dic_file): | |||||||
|             path_dict[k]*=0.9*max_keyweight/keyweight |             path_dict[k]*=0.9*max_keyweight/keyweight | ||||||
|         save(path_dict,dic_file) |         save(path_dict,dic_file) | ||||||
| 
 | 
 | ||||||
|  | # catch all unavailable (python < 2.5) | ||||||
|  | try: | ||||||
|  |     all | ||||||
|  | except: | ||||||
|  |     def all(iterable): | ||||||
|  |         for element in iterable: | ||||||
|  |             if not element: | ||||||
|  |                 return False | ||||||
|  |         return True | ||||||
|  | 
 | ||||||
| def find_matches(dirs,patterns,path_dict,result_list,ignore_case,max_matches): | def find_matches(dirs,patterns,path_dict,result_list,ignore_case,max_matches): | ||||||
|     """Find max_matches paths that match the pattern, and add them to the result_list""" |     """Find max_matches paths that match the pattern, and add them to the result_list""" | ||||||
|     for path,count in dirs: |     for path,count in dirs: | ||||||
| @ -158,7 +169,10 @@ else: | |||||||
| 
 | 
 | ||||||
|         dirs=path_dict.items() |         dirs=path_dict.items() | ||||||
|         dirs.sort(key=lambda e:e[1],reverse=True) |         dirs.sort(key=lambda e:e[1],reverse=True) | ||||||
|         max_matches = 9 if completion else 1 |         if completion: | ||||||
|  |             max_matches = 9 | ||||||
|  |         else: | ||||||
|  |             max_matches = 1 | ||||||
|         find_matches(dirs,patterns,path_dict,results,False,max_matches) |         find_matches(dirs,patterns,path_dict,results,False,max_matches) | ||||||
|         dirs=path_dict.items() #we need to recreate the list since the first iteration potentially deletes paths |         dirs=path_dict.items() #we need to recreate the list since the first iteration potentially deletes paths | ||||||
|         dirs.sort(key=lambda e:e[1],reverse=True) |         dirs.sort(key=lambda e:e[1],reverse=True) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user