Skip to content

Commit

Permalink
Use the helper method for parsing the config
Browse files Browse the repository at this point in the history
  • Loading branch information
wafflespeanut committed Aug 10, 2016
1 parent 288fc15 commit e2017aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
19 changes: 5 additions & 14 deletions handlers/label_watchers/__init__.py
@@ -1,17 +1,12 @@
from eventhandler import EventHandler
import ConfigParser
from helpers import get_people_from_config

import os

LABEL_WATCHERS_CONFIG_FILE = os.path.join(os.path.dirname(__file__),
'watchers.ini')


def get_label_config():
config = ConfigParser.ConfigParser()
config.read(LABEL_WATCHERS_CONFIG_FILE)
return config


def build_label_message(mentions):
message = ['cc']
for watcher in mentions:
Expand All @@ -23,13 +18,9 @@ def build_label_message(mentions):
class LabelWatchersHandler(EventHandler):
def on_issue_labeled(self, api, payload):
new_label = payload['label']['name']
config = get_label_config()

repo = api.owner + '/' + api.repo
try:
watchers = config.items(repo)
except ConfigParser.NoSectionError:
return # No watchers
watchers = get_people_from_config(api, LABEL_WATCHERS_CONFIG_FILE)
if not watchers:
return

mentions = []
creator = None
Expand Down
5 changes: 5 additions & 0 deletions helpers.py
Expand Up @@ -11,6 +11,11 @@


def get_people_from_config(api, config_abs_path):
'''
Gets the people listed under a particular repo from a config file.
Note that the names (despite how they're in the file) will always
be parsed to 'lowercase'.
'''
config = ConfigParser.ConfigParser()
config.read(config_abs_path)
repo = api.owner + '/' + api.repo
Expand Down

0 comments on commit e2017aa

Please sign in to comment.