mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 15:12:20 +00:00 
			
		
		
		
	#78 Disable when can't import CommandNotFound
				
					
				
			This commit is contained in:
		| @@ -1,8 +1,10 @@ | |||||||
| import sys |  | ||||||
|  |  | ||||||
| def match(command, settings): |  | ||||||
| try: | try: | ||||||
|     import CommandNotFound |     import CommandNotFound | ||||||
|  | except ImportError: | ||||||
|  |     enabled_by_default = False | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def match(command, settings): | ||||||
|     if 'not found' in command.stderr: |     if 'not found' in command.stderr: | ||||||
|         try: |         try: | ||||||
|             c = CommandNotFound.CommandNotFound() |             c = CommandNotFound.CommandNotFound() | ||||||
| @@ -12,17 +14,10 @@ def match(command, settings): | |||||||
|         except IndexError: |         except IndexError: | ||||||
|             # IndexError is thrown when no matching package is found |             # IndexError is thrown when no matching package is found | ||||||
|             return False |             return False | ||||||
|     except: |  | ||||||
|         return False |  | ||||||
|  |  | ||||||
| def get_new_command(command, settings): | def get_new_command(command, settings): | ||||||
|     try: |  | ||||||
|         import CommandNotFound |  | ||||||
|     c = CommandNotFound.CommandNotFound() |     c = CommandNotFound.CommandNotFound() | ||||||
|         if 'not found' in command.stderr: |  | ||||||
|     pkgs = c.getPackages(command.script.split(" ")[0]) |     pkgs = c.getPackages(command.script.split(" ")[0]) | ||||||
|     name, _ = pkgs[0] |     name, _ = pkgs[0] | ||||||
|             return "sudo apt-get install %s" % name |     return "sudo apt-get install {} && {}".format(name, command.script) | ||||||
|     except: |  | ||||||
|         sys.stderr.write("Can't apt fuck\n") |  | ||||||
|         return "" |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user