INNER CODE UNIT · Python
apply_label
openfaas/workshop · issue-bot-secrets/bot-handler/handler.py:42
def apply_label(polarity, issue_number, repo, positive_threshold):
with open("/var/openfaas/secrets/auth-token","r") as authToken:
g = Github(authToken.read())
repo = g.get_repo(repo)
issue = repo.get_issue(issue_number)
has_label_positive = False
has_label_review = False
for label in issue.labels:
if label == "positive":
has_label_positive = True
if label == "review":
has_label_review = True
if polarity > positive_threshold and not has_label_positive:
issue.set_labels("positive")