Skip to content

Commit

Permalink
Refactor to use slightly more efficient list construction
Browse files Browse the repository at this point in the history
Appending is a bit faster than constucting new lists on top of the old
ones. It also avoids the need to use two lists.
  • Loading branch information
eli-schwartz committed Jun 19, 2018
1 parent 586f29b commit c7b052d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/aurman/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ def pacman(options_as_string: str, fetch_output: bool, dir_to_execute: str = Non
:return: empty list in case of "fetch_output"=False, otherwise the lines of the pacman output as list.
one line of output is one item in the list.
"""
# I cannot be bothered to untangle the tremendous layers of strings absolutely everywhere.
# Ruthlessly paper over this by using a shell-like parser to convert the weird string
# representation into proper lists. FIXME: teach aurman to natively use lists everywhere.
options = shlex.split(options_as_string)
if sudo:
pacman_query = ["sudo", "pacman"]
else:
pacman_query = ["pacman"]

if use_ask:
options = ['--ask=4'] + options
pacman_query += ['--ask=4']

if sudo:
pacman_query = ["sudo", "pacman"] + options
else:
pacman_query = ["pacman"] + options
# I cannot be bothered to untangle the tremendous layers of strings absolutely everywhere.
# Ruthlessly paper over this by using a shell-like parser to convert the weird string
# representation into proper lists. FIXME: teach aurman to natively use lists everywhere.
pacman_query += shlex.split(options_as_string)

kwargs = {'cwd': dir_to_execute}

Expand Down

0 comments on commit c7b052d

Please sign in to comment.