def scan_github_issues(config):
    pattern = re.compile(config['regex_pattern'], flags=re.I)
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    try:
        with open('github-notify.json') as f:
            known = json.load(f)
    except IOError, ValueError:
        known = {}

    g = Github(client_id=config['github_client_id'],
               client_secret=config['github_client_secret'],
               per_page=100)

    if not isinstance(config['github_repository'], list):
        repos = [config['github_repository']]
    else:
        repos = config['github_repository']

    for repo_name in repos:
        repo = g.get_repo(repo_name)

        for pull in repo.get_pulls():
            if pull.number in known.get(repo_name, []):
                continue

            try:
                if pattern.search(pull.title):
                    alert(config, pull, known, repo_name)
                    continue
            except TypeError:
                pass

            try:
                if pattern.search(pull.body):
                    alert(config, pull, known, repo_name)
                    continue
            except TypeError:
                pass

            for pull_file in pull.get_files():
                if pattern.search(pull_file.filename):
                    alert(config, pull, known, repo_name)
                    break

            for comment in pull.get_comments():
                try:
                    if pattern.search(comment.body):
                        alert(config, pull, known, repo_name)
                        break
                except TypeError:
                    pass

            for commit in pull.get_commits():
                try:
                    if pattern.search(commit.commit.message):
                        alert(config, pull, known, repo_name)
                        break
                except TypeError:
                    pass

            for comment in pull.get_issue_comments():
                try:
                    if pattern.search(comment.body):
                        alert(config, pull, known, repo_name)
                        break
                except TypeError:
                    pass

        for issue in repo.get_issues():
            if issue.number in known.get(repo_name, []):
                continue

            if issue.pull_request is not None:
                continue

            try:
                if pattern.search(issue.title):
                    alert(config, issue, known, repo_name)
                    continue
            except TypeError:
                pass

            try:
                if pattern.search(issue.body):
                    alert(config, issue, known, repo_name)
                    continue
            except TypeError:
                pass

            for comment in issue.get_comments():
                try:
                    if pattern.search(comment.body):
                        alert(config, issue, known, repo_name)
                        break
                except TypeError:
                    pass

    try:
        with open('github-notify.json', 'w+') as f:
            json.dump(known, f, indent=4, sort_keys=True)
    except (IOError, ValueError):
        pass
dataset/ETHPy150Open sivel/github-notify/github-notify.py/scan_github_issues/original