1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-20 01:28:56 +00:00

Reformat keyword detection if statement

This commit is contained in:
Philip Arola 2019-10-30 11:33:46 -07:00
parent 0ad479b4b0
commit 395d69eadb

View File

@ -9,21 +9,16 @@ def match(command):
def get_new_command(command): def get_new_command(command):
# Find the argument that is the package name # Find the argument that is the package name
for script_part in command.script_parts: for script_part in command.script_parts:
if script_part in ["choco", "cinst", "install"]: if (
# Need exact match (bc chocolatey is a package) script_part not in ["choco", "cinst", "install"]
continue # Need exact match (bc chocolatey is a package)
if script_part.startswith('-'): and not script_part.startswith('-')
# Leading hyphens are parameters; some packages contain them though # Leading hyphens are parameters; some packages contain them though
continue and '=' not in script_part and '/' not in script_part
if '=' in script_part or '/' in script_part: # These are certainly parameters
# These are certainly parameters ):
continue return command.script.replace(script_part, script_part + ".install")
else: return []
packageName = script_part
# Find the name of the broken package, and append metapackage names
if not packageName:
return False
return(command.script.replace(packageName, packageName + ".install"))
enabled_by_default = bool(which("choco")) or bool(which("cinst")) enabled_by_default = bool(which("choco")) or bool(which("cinst"))