예제 #1
0
def createGraphs(owner, repo, htmldir):
    repoPath = os.path.join(owner, repo)
    # No clue why readline is returning single characters, so let's do it this way:
    with open(os.path.join(repoPath, 'first-interactions.txt')) as newcomersFile:
        newcomers = newcomersFile.read().split('\n')
    html = {'newcomers-ramp': graphNewcomers(repoPath, newcomers)}

    info = [['responder', 'Bug triaging', 'a contributor comments on an issue opened by another person'],
            ['merger', 'Merger', 'a contributor merges a pull request'],
            ['reporter', 'Issue reporter', 'a contributor opens an issue'],
            ['reviewer', 'Pull request reviewer', 'a contributor comments on a pull request opened by another person'],
           ]

    for i in info:
        with open(os.path.join(repoPath, i[0] + 's.txt')) as f:
            contributors = f.read()
        i.append(sortContributors(contributors))
        deltaResponse, noResponse = getRampTime(newcomers, i[3], i[0])
        html[i[0] + '-ramp'] = graphRampTime(deltaResponse, noResponse,
                      '%s ramp up time for newcomers to<br>' % i[1] + repoPath,
                      '<br>Number of days before %s' % i[2],
                      os.path.join(repoPath, i[0] + 's-rampup.html'))
        freq, nodata = getFrequency(i[3])
        html[i[0] + '-freq'] = graphFrequency(freq,
                      '%s frequency for contributors to<br>' % i[1] + repoPath,
                      '<br>Length of time (weeks) spent in that role',
                      os.path.join(repoPath, i[0] + 's-frequency.html'))
    coords = prOpenTimes(owner, repo)
    html['mergetime'] = graphMergeDelay(coords)

    # Use bootstrap to generate mobile-friendly webpages
    overwritehtml(htmldir, owner, repo, html)
예제 #2
0
def createGraphs(owner, repo, htmldir):
    repoPath = os.path.join(owner, repo)
    # No clue why readline is returning single characters, so let's do it this way:
    with open(os.path.join(repoPath,
                           'first-interactions.txt')) as newcomersFile:
        newcomers = newcomersFile.read().split('\n')
    html = {'newcomers-ramp': graphNewcomers(repoPath, newcomers)}

    info = [
        [
            'responder', 'Bug triaging',
            'a contributor comments on an issue opened by another person'
        ],
        ['merger', 'Merger', 'a contributor merges a pull request'],
        ['reporter', 'Issue reporter', 'a contributor opens an issue'],
        [
            'reviewer', 'Pull request reviewer',
            'a contributor comments on a pull request opened by another person'
        ],
    ]

    for i in info:
        with open(os.path.join(repoPath, i[0] + 's.txt')) as f:
            contributors = f.read()
        i.append(sortContributors(contributors))
        deltaResponse, noResponse = getRampTime(newcomers, i[3], i[0])
        html[i[0] + '-ramp'] = graphRampTime(
            deltaResponse, noResponse,
            '%s ramp up time for newcomers to<br>' % i[1] + repoPath,
            '<br>Number of days before %s' % i[2],
            os.path.join(repoPath, i[0] + 's-rampup.html'))
        freq, nodata = getFrequency(i[3])
        html[i[0] + '-freq'] = graphFrequency(
            freq, '%s frequency for contributors to<br>' % i[1] + repoPath,
            '<br>Length of time (weeks) spent in that role',
            os.path.join(repoPath, i[0] + 's-frequency.html'))
    coords = prOpenTimes(owner, repo)
    html['mergetime'] = graphMergeDelay(coords)
    if 'all-comments-sentiment.txt' in os.listdir(repoPath):
        html[
            'sentimentwarning'] = '<p><b>**WARNING** The sentiment model is not very good at classifying sentences yet. Take these graphs with a giant lump of salt.</b></p>'
        html['sentimentgraph'] = graphSentiment(repoPath, False)
        html['sentimentstats'] = htmlSentimentStats(repoPath)
    else:
        html['sentimentwarning'] = ''
        html[
            'sentimentgraph'] = '<p>More data coming soon! Click another tab.</p>'
        html['sentimentstats'] = ''

    # Use bootstrap to generate mobile-friendly webpages
    overwritehtml(htmldir, owner, repo, html)