Skip to content

Commit

Permalink
Replace conditional validation with filtering
Browse files Browse the repository at this point in the history
This commit modifies the `parse_unspecified_argument_list` function to filter out unwanted elements from the `unknowns` list instead of using a conditional check with an `if` statement. This change improves code readability and efficiency by utilizing list comprehension to create a new list that excludes elements equal to "=".
  • Loading branch information
ddx2tb committed Aug 2, 2024
1 parent 919c904 commit 7d40b06
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,13 @@ def parse_unspecified_argument_list(unknowns: list, multiple: bool = False, err:
argument value value ...
which isn't am error if multiple is specified
"""
tmp_list = unknowns[:] # wastes a few bytes, but avoids any collateral effect of the destructive nature of the pop method()
tmp_list = [a for a in unknowns if a != "="] # wastes a few bytes, but avoids any collateral effect of the destructive nature of the pop method()
config = {}
key = None
last_key = None
while tmp_list:
element = tmp_list.pop(0) # retrieve an element of the list

if element == '=':
continue

if element.startswith('--'): # is an argument ?
if '=' in element: # uses the arg=value syntax ?
key, value = [x.strip() for x in element[2:].split('=', 1)]
Expand Down

0 comments on commit 7d40b06

Please sign in to comment.