refactor dir list reading
This commit is contained in:
parent
3bbe6b367a
commit
137e1d5195
1 changed files with 7 additions and 13 deletions
|
@ -14,27 +14,21 @@ def readInstallDirectoriesFromConfig():
|
|||
"""Read the config file and find install dirs.
|
||||
|
||||
Returns:
|
||||
a list consisting of the install directories specified in
|
||||
a set consisting of the install directories specified in
|
||||
the config file. An empty list in case of non-existing config
|
||||
file.
|
||||
|
||||
"""
|
||||
installdirs = []
|
||||
try:
|
||||
with open(CONFIGFILE, "r") as configfile:
|
||||
for line in [l.strip("\n") for l in configfile.readlines() if
|
||||
l.startswith(CONFIG_INSTALLDIR + CONFIG_SEPARATOR)]:
|
||||
try:
|
||||
installdirs.append(line.split(CONFIG_SEPARATOR,
|
||||
maxsplit=1 # max 2 parts
|
||||
)[1])
|
||||
except IndexError:
|
||||
print("Debug: impossible index error " +
|
||||
"in config file reading.")
|
||||
return installdirs
|
||||
return {
|
||||
line.strip("\n").split(CONFIG_SEPARATOR, maxsplit=1)[1]
|
||||
for line in configfile.readlines()
|
||||
if line.startswith(CONFIG_INSTALLDIR + CONFIG_SEPARATOR)
|
||||
} # set for removind duplicates
|
||||
except FileNotFoundError:
|
||||
print("Debug: no config file found.")
|
||||
return []
|
||||
return set()
|
||||
|
||||
|
||||
def removeInstallationLinks(where):
|
Loading…
Reference in a new issue