Fix crash due to remaining raise() in getDepends()

This commit is contained in:
rubenwardy 2018-05-27 23:02:11 +01:00
parent d046de8057
commit d0969263ba
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C

@ -299,56 +299,54 @@ def getDepends(package):
if url.netloc == "github.com": if url.netloc == "github.com":
urlmaker = GithubURLMaker(url) urlmaker = GithubURLMaker(url)
else: else:
raise TaskError("Unsupported repo") return {}
result = {} result = {}
if urlmaker.isValid(): if not urlmaker.isValid():
# return {}
# Try getting depends on mod.conf
#
try:
contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8")
conf = parseConf(contents)
for key in ["depends", "optional_depends"]:
try:
result[key] = conf[key]
except KeyError:
pass
except HTTPError: #
print("mod.conf does not exist") # Try getting depends on mod.conf
#
try:
contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8")
conf = parseConf(contents)
for key in ["depends", "optional_depends"]:
try:
result[key] = conf[key]
except KeyError:
pass
if "depends" in result or "optional_depends" in result: except HTTPError:
return result print("mod.conf does not exist")
#
# Try depends.txt
#
import re
pattern = re.compile("^([a-z0-9_]+)\??$")
try:
contents = urllib.request.urlopen(urlmaker.getDependsURL()).read().decode("utf-8")
soft = []
hard = []
for line in contents.split("\n"):
line = line.strip()
if pattern.match(line):
if line[len(line) - 1] == "?":
soft.append( line[:-1])
else:
hard.append(line)
result["depends"] = ",".join(hard)
result["optional_depends"] = ",".join(soft)
except HTTPError:
print("depends.txt does not exist")
if "depends" in result or "optional_depends" in result:
return result return result
else:
print(TaskError("non-github depends detector not implemented yet!")) #
return {} # Try depends.txt
#
import re
pattern = re.compile("^([a-z0-9_]+)\??$")
try:
contents = urllib.request.urlopen(urlmaker.getDependsURL()).read().decode("utf-8")
soft = []
hard = []
for line in contents.split("\n"):
line = line.strip()
if pattern.match(line):
if line[len(line) - 1] == "?":
soft.append( line[:-1])
else:
hard.append(line)
result["depends"] = ",".join(hard)
result["optional_depends"] = ",".join(soft)
except HTTPError:
print("depends.txt does not exist")
return result
def importDependencies(package, mpackage_cache): def importDependencies(package, mpackage_cache):