-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrgConsolidation.py
106 lines (88 loc) · 3.91 KB
/
OrgConsolidation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# -*- coding: utf-8 -*-
# ########################## Copyrights and license ############################
# #
# Copyright 2016 David Roegiers <david.roegiers@gmail.com> #
# #
# This file is part of the author's master thesis on OSS research : #
# https://github.com/droegier/ThesisOSS #
# #
# This script is free software: you can redistribute it and/or modify it under #
# the terms of the GNU Lesser General Public License as published by the Free #
# Software Foundation, either version 3 of the License, or (at your option) #
# any later version. #
# #
# This script is based on the PyGithub library v 1.26.0 #
# http://pygithub.github.io/PyGithub/v1/introduction.html #
# #
# ##############################################################################
"""
This is the main file. It illustrates how repositories are collected, stored, and managed from the GitHub API v3,
using the PyGitHub library. Additionally, it displays the organisations and repositories that were gathered for
the analysis of the research paper.
"""
import time
import ssl
import os
import xml.etree.ElementTree as ET
import Organisation
import csv
import sys
class OrgConsolidation(object):
def __init__(self):
pass
def __del__(self):
pass
def __enter__(self):
pass
def __exit__(self, type, value, traceback):
pass
def getTimeBetweenActions(self):
outfile = 'data/' + 'inter_action_time.csv'
#delete file if it exists
try:
os.remove(outfile)
except OSError:
pass
with open(outfile, 'w') as csvfile:
csvwrite = csv.writer(csvfile)
subdirs = [x[0] for x in os.walk('data')]
subdirs = [ name for name in os.listdir('data') if os.path.isdir(os.path.join('data', name)) ]
for subdir in subdirs:
rep = subdir
print 'organisation : ' + subdir
if os.path.exists('data/' + subdir + '/' + 'participants.xml'):
org_tree = ET.parse('data/' + subdir + '/' + 'participants.xml')
else:
continue
org_root = org_tree.getroot()
for participant in org_root:
list = []
for period in participant:
list.append(int(period.get('date')))
list = sorted(list)
for j in range(1,len(list)):
r = int(str(list[j-1])[0:4])
if r < 2005:
pass
else:
diff = (int(str(list[j])[0:4])-int(str(list[j-1])[0:4]))*52+int(str(list[j])[4:])-int(str(list[j-1])[4:])
if diff > 700:
pass
csvwrite.writerow([diff])
print "done"
return True
#TODO this function is nowhere yet
def gatherAllActions(self):
outfile = 'data/' + 'everything.csv'
#delete file if it exists
try:
os.remove(outfile)
except OSError:
pass
with open(outfile, 'w') as csvfile:
csvwrite = csv.writer(csvfile)
subdirs = [ name for name in os.listdir('data') if os.path.isdir(os.path.join('data', name)) ]
for subdir in subdirs:
pass
print "done"
return True