diff options
Diffstat (limited to 'app/tasks/importtasks.py')
-rw-r--r-- | app/tasks/importtasks.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py index 1950d5b..7940a17 100644 --- a/app/tasks/importtasks.py +++ b/app/tasks/importtasks.py @@ -30,6 +30,12 @@ class GithubURLMaker: def isValid(self): return self.baseUrl is not None + def getRepoURL(self): + return "https://github.com/" + self.user + "/" + self.repo + ".git" + + def getIssueTrackerURL(self): + return "https://github.com/" + self.user + "/" + self.repo + "/issues/" + def getModConfURL(self): return self.baseUrl + "/mod.conf" @@ -70,10 +76,11 @@ def getMeta(urlstr): if not urlmaker.isValid(): raise TaskError("Error! Url maker not valid") - print(urlmaker.getModConfURL()) - result = {} + result["repo"] = urlmaker.getRepoURL() + result["issueTracker"] = urlmaker.getIssueTrackerURL() + try: contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8") conf = parseConf(contents) @@ -82,11 +89,12 @@ def getMeta(urlstr): result[key] = conf[key] except KeyError: pass - - print(conf) except OSError: print("mod.conf does not exist") + if "name" in result: + result["title"] = result["name"].replace("_", " ").title() + if not "description" in result: try: contents = urllib.request.urlopen(urlmaker.getDescURL()).read().decode("utf-8") @@ -94,6 +102,12 @@ def getMeta(urlstr): except OSError: print("description.txt does not exist!") + if "description" in result: + desc = result["description"] + idx = desc.find(".") + 1 + cutIdx = min(len(desc), 200 if idx < 5 else idx) + result["short_description"] = desc[:cutIdx] + return result @celery.task() |