mirror of
				https://github.com/wting/autojump
				synced 2025-06-13 12:54:07 +00:00 
			
		
		
		
	Merge 54e5cb0356 into ee21082751
				
					
				
			This commit is contained in:
		
						commit
						f5ec637551
					
				
							
								
								
									
										21
									
								
								bin/autojump
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								bin/autojump
									
									
									
									
									
								
							| @ -129,8 +129,8 @@ def parse_arguments(): | ||||
|         help='show database entries and their key weights', | ||||
|     ) | ||||
|     parser.add_argument( | ||||
|         '-v', '--version', action='version', version='%(prog)s v' + | ||||
|         VERSION, help='show version information', | ||||
|         '-v', '--version', action='version', version='%(prog)s v' + VERSION, | ||||
|         help='show version information', | ||||
|     ) | ||||
| 
 | ||||
|     return parser.parse_args() | ||||
| @ -188,18 +188,15 @@ def find_matches(entries, needles, check_entries=True): | ||||
|     else: | ||||
|         path_exists = lambda _: True | ||||
| 
 | ||||
|     data = sorted( | ||||
|         entries, | ||||
|         key=attrgetter('weight', 'path'), | ||||
|         reverse=True, | ||||
|     ) | ||||
| 
 | ||||
|     return ifilter( | ||||
|         lambda entry: not is_cwd(entry) and path_exists(entry), | ||||
|         chain( | ||||
|             match_consecutive(needles, data, ignore_case), | ||||
|             match_fuzzy(needles, data, ignore_case), | ||||
|             match_anywhere(needles, data, ignore_case), | ||||
|         sorted( | ||||
|             set(chain( | ||||
|                 match_consecutive(needles, entries, ignore_case), | ||||
|                 match_fuzzy(needles, entries, ignore_case), | ||||
|                 match_anywhere(needles, entries, ignore_case), | ||||
|             )), key=attrgetter('weight', 'path'), | ||||
|             reverse=True, | ||||
|         ), | ||||
|     ) | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										1
									
								
								bin/autojump.py
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								bin/autojump.py
									
									
									
									
									
										Symbolic link
									
								
							| @ -0,0 +1 @@ | ||||
| autojump | ||||
							
								
								
									
										17
									
								
								tests/integration/autojump_test.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/integration/autojump_test.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| #!/usr/bin/env python | ||||
| # -*- coding: utf-8 -*- | ||||
| import os | ||||
| import sys | ||||
| 
 | ||||
| sys.path.append(os.path.join(os.getcwd(), 'bin'))  # noqa | ||||
| from autojump import find_matches | ||||
| from autojump_data import entriefy | ||||
| 
 | ||||
| 
 | ||||
| def test_find_matches_returns_unique_results(tmpdir): | ||||
|     path = str(tmpdir) | ||||
|     needle = str(os.path.basename(tmpdir)) | ||||
| 
 | ||||
|     matches = find_matches(entriefy({path: 10}), [needle]) | ||||
| 
 | ||||
|     assert list(matches) == list(entriefy({path: 10})) | ||||
| @ -19,8 +19,8 @@ class TestMatchAnywhere(object): | ||||
|     entry4 = Entry('/中/zhong/国/guo', 10) | ||||
|     entry5 = Entry('/is\'t/this/a/b*tchin/edge/case?', 10) | ||||
|     win_entry1 = Entry('C:\\foo\\bar\\baz', 10) | ||||
|     win_entry2 = Entry('D:\Program Files (x86)\GIMP', 10) | ||||
|     win_entry3 = Entry('C:\Windows\System32', 10) | ||||
|     win_entry2 = Entry('D:\\Program Files (x86)\\GIMP', 10) | ||||
|     win_entry3 = Entry('C:\\Windows\\System32', 10) | ||||
| 
 | ||||
|     @pytest.fixture | ||||
|     def haystack(self): | ||||
| @ -75,9 +75,9 @@ class TestMatchConsecutive(object): | ||||
|     entry4 = Entry('/中/zhong/国/guo', 10) | ||||
|     entry5 = Entry('/日/本', 10) | ||||
|     entry6 = Entry('/is\'t/this/a/b*tchin/edge/case?', 10) | ||||
|     win_entry1 = Entry('C:\Foo\Bar\Baz', 10) | ||||
|     win_entry2 = Entry('D:\Program Files (x86)\GIMP', 10) | ||||
|     win_entry3 = Entry('C:\Windows\System32', 10) | ||||
|     win_entry1 = Entry('C:\\Foo\\Bar\\Baz', 10) | ||||
|     win_entry2 = Entry('D:\\Program Files (x86)\\GIMP', 10) | ||||
|     win_entry3 = Entry('C:\\Windows\\System32', 10) | ||||
| 
 | ||||
|     @pytest.fixture | ||||
|     def haystack(self): | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user