Parent: [c9d94b] (diff)

Child: [831432] (diff)

Download this file

flossmole.py    290 lines (262 with data), 13.4 kB

  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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# This Source Code Form of OSSEval is subject to the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE, v. 3.0. If a copy of the AGPL was not
# distributed with this file, You can obtain one at http://www.gnu.org/licenses/agpl.txt
#
# OSSeval is powered by the SOS Open Source AGPL edition.
# The AGPL requires that you do not remove the SOS Open Source attribution and copyright
# notices from the user interface (see section 5.d below).
# Commercial licenses are available and do not require any SOS Open Source attributions
# or visible copyright notices but they are not permitted under this license.
# OSSEval Copyright 2014 Bitergium SLL
# SOS Open Source Copyright 2012 Roberto Galoppini
# Author: Davide Galletti
from utils import Configuration, Forges
from django.db import connections
class FSF():
@staticmethod
def search(name):
project_list = []
cursor = connections['local_flossmole'].cursor()
parameters = { 'limit': Configuration.max_number_of_records }
cursor.execute("SELECT proj_unixname, datasource_id, proj_long_name, desc_long FROM fsf_projects WHERE LOWER(proj_unixname) LIKE '%%" + name.lower() + "%%' LIMIT %(limit)s", parameters)
results = cursor.fetchall()
for record in results:
fp = FlossmoleProject()
fp.id = record[0]
fp.id_forge = Forges.FSF
fp.datasource_id = record[1]
fp.name = record[2]
fp.description = record[3]
project_list.append(fp)
return project_list
@staticmethod
def getProjectInfo(project_identifier):
info = {}
cursor = connections['local_flossmole'].cursor()
cursor.execute("SELECT max(datasource_id) FROM fsf_projects")
row = cursor.fetchone()
datasource_id = row[0]
parameters = { 'datasource_id': datasource_id, 'project_identifier': project_identifier }
cursor.execute("SELECT proj_long_name, desc_long, url, real_url, released_on, proj_num FROM fsf_projects WHERE proj_unixname=%(project_identifier)s and datasource_id=%(datasource_id)s", parameters)
result = cursor.fetchone()
info['name'] = result[0]
info['desc_long'] = result[1]
info['url'] = result[2]
info['real_url'] = result[3]
info['released_on'] = result[4]
proj_num = result[5]
info['licenses'] = []
parameters = { 'datasource_id': datasource_id, 'proj_num': proj_num }
cursor.execute("SELECT license FROM fsf_project_licenses WHERE proj_num=%(proj_num)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
info['licenses'].append(record[0])
info['developers'] = []
cursor.execute("SELECT person_name, role, email FROM fsf_developer_projects WHERE proj_num=%(proj_num)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
developer = {}
developer['person_name'] = record[0]
developer['role'] = record[1]
developer['email'] = record[2]
info['developers'].append(developer)
info['categories'] = []
parameters = { 'datasource_id': datasource_id, 'proj_num': proj_num }
cursor.execute("SELECT project_category_title FROM fsf_project_categories WHERE proj_num=%(proj_num)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
info['categories'].append(record[0])
info['requirements'] = []
cursor.execute("SELECT requirement, requirement_type FROM fsf_project_requirements WHERE proj_num=%(proj_num)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
requirement = {}
requirement['requirement'] = record[0]
requirement['requirement_type'] = record[1]
info['requirements'].append(requirement)
return info
class FC():
@staticmethod
def search(name):
project_list = []
cursor = connections['local_flossmole'].cursor()
parameters = { 'name': name, 'limit': Configuration.max_number_of_records }
cursor.execute("SELECT project_id, datasource_id, projectname_full, desc_short FROM fm_projects WHERE LOWER(projectname_full) LIKE '%%" + name.lower() + "%%' LIMIT %(limit)s", parameters)
results = cursor.fetchall()
for record in results:
fp = FlossmoleProject()
fp.id = record[0]
fp.id_forge = Forges.FC
fp.datasource_id = record[1]
fp.name = record[2]
fp.description = record[3]
project_list.append(fp)
return project_list
@staticmethod
def getProjectInfo(project_identifier):
info = {}
cursor = connections['local_flossmole'].cursor()
cursor.execute("SELECT max(datasource_id) FROM fm_projects")
row = cursor.fetchone()
datasource_id = row[0]
parameters = { 'datasource_id': datasource_id, 'project_identifier': project_identifier }
cursor.execute('''SELECT date_added, date_updated, projectname_full, desc_short, desc_full, vitality_score,
popularity_score, rating, rating_count, subscriptions, url_homepage, url_tgz, url_changelog,
url_cvs, url_bugtracker, url_list, url_demo, url_project_page, license, latest_release_version,
latest_release_date, screenshot_thumb, calc_dev_count FROM fm_projects
WHERE project_id=%(project_identifier)s and datasource_id=%(datasource_id)s''', parameters)
result = cursor.fetchone()
info['date_added'] = result[0]
info['date_updated'] = result[1]
info['projectname_full'] = result[2]
info['desc_short'] = result[3]
info['desc_full'] = result[4]
info['vitality_score'] = result[5]
info['popularity_score'] = result[6]
info['rating'] = result[7]
info['rating_count'] = result[8]
info['subscriptions'] = result[9]
info['url_homepage'] = result[10]
info['url_tgz'] = result[11]
info['url_changelog'] = result[12]
info['url_cvs'] = result[13]
info['url_bugtracker'] = result[14]
info['url_list'] = result[15]
info['url_demo'] = result[16]
info['url_project_page'] = result[17]
info['license'] = result[18]
info['latest_release_version'] = result[19]
info['latest_release_date'] = result[20]
info['screenshot_thumb'] = result[21]
info['calc_dev_count'] = result[22]
parameters = { 'datasource_id': datasource_id, 'project_id': project_identifier }
info['authors'] = []
cursor.execute("SELECT author_name, author_url, author_role FROM fm_project_authors WHERE project_id=%(project_id)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
author = {}
author['author_name'] = record[0]
author['author_url'] = record[1]
author['author_role'] = record[2]
info['authors'].append(author)
info['dependencies'] = []
cursor.execute("SELECT dependency_project_id, dependency_project_title FROM fm_project_dependencies WHERE project_id=%(project_id)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
dependency = {}
dependency['dependency_project_id'] = record[0]
dependency['dependency_project_title'] = record[1]
info['dependencies'].append(dependency)
info['tags'] = []
cursor.execute("SELECT tag_name FROM fm_project_tags WHERE project_id=%(project_id)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
info['tags'].append(record[0])
return info
class GC():
@staticmethod
def search(name):
project_list = []
cursor = connections['local_flossmole'].cursor()
parameters = { 'name': name, 'limit': Configuration.max_number_of_records }
cursor.execute("SELECT proj_name, datasource_id, proj_name, project_summary FROM gc_projects WHERE LOWER(proj_name) LIKE '%%" + name.lower() + "%%' LIMIT %(limit)s", parameters)
results = cursor.fetchall()
for record in results:
fp = FlossmoleProject()
fp.id = record[0]
fp.id_forge = Forges.GC
fp.datasource_id = record[1]
fp.name = record[2]
fp.description = record[3]
project_list.append(fp)
return project_list
@staticmethod
def getProjectInfo(project_identifier):
info = {}
cursor = connections['local_flossmole'].cursor()
cursor.execute("SELECT max(datasource_id) FROM gc_projects")
row = cursor.fetchone()
datasource_id = row[0]
parameters = { 'datasource_id': datasource_id, 'project_identifier': project_identifier }
cursor.execute("SELECT last_updated, code_license, code_url, project_summary, project_description FROM gc_projects WHERE proj_name=%(project_identifier)s and datasource_id=%(datasource_id)s", parameters)
result = cursor.fetchone()
info['last_updated'] = result[0]
info['code_license'] = result[1]
info['code_url'] = result[2]
info['project_summary'] = result[3]
info['project_description'] = result[4]
info['blogs'] = []
cursor.execute("SELECT blog_title, blog_link FROM gc_project_blogs WHERE proj_name=%(project_identifier)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
blog = {}
blog['blog_title'] = record[0]
blog['blog_link'] = record[1]
info['blogs'].append(blog)
info['groups'] = []
cursor.execute("SELECT group_name, group_url FROM gc_project_groups WHERE proj_name=%(project_identifier)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
group = {}
group['group_name'] = record[0]
group['group_url'] = record[1]
info['groups'].append(group)
info['labels'] = []
cursor.execute("SELECT label FROM gc_project_labels WHERE proj_name=%(project_identifier)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
info['labels'].append(record[0])
info['links'] = []
cursor.execute("SELECT link_title, link FROM gc_project_links WHERE proj_name=%(project_identifier)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
link = {}
link['link_title'] = record[0]
link['link'] = record[1]
info['links'].append(link)
info['people'] = []
cursor.execute("SELECT person_name, user_id, role FROM gc_project_people WHERE proj_name=%(project_identifier)s and datasource_id=%(datasource_id)s", parameters)
results = cursor.fetchall()
for record in results:
person = {}
person['person_name'] = record[0]
person['user_id'] = record[1]
person['role'] = record[1]
info['people'].append(person)
return info
class GH():
@staticmethod
def search(name):
project_list = []
cursor = connections['local_flossmole'].cursor()
parameters = { 'name': name, 'limit': Configuration.max_number_of_records }
cursor.execute("SELECT project_name, datasource_id, project_name, description FROM gh_projects WHERE LOWER(project_name) LIKE '%%" + name.lower() + "%%' LIMIT %(limit)s", parameters)
results = cursor.fetchall()
for record in results:
fp = FlossmoleProject()
fp.id = record[0]
fp.id_forge = Forges.GH
fp.datasource_id = record[1]
fp.name = record[2]
fp.description = record[3]
project_list.append(fp)
return project_list
@staticmethod
def getProjectInfo(project_identifier):
info = {}
cursor = connections['local_flossmole'].cursor()
cursor.execute("SELECT max(datasource_id) FROM gh_projects")
row = cursor.fetchone()
datasource_id = row[0]
parameters = { 'datasource_id': datasource_id, 'project_identifier': project_identifier }
cursor.execute("SELECT developer_name, description FROM gh_projects WHERE project_name=%(project_identifier)s and datasource_id=%(datasource_id)s", parameters)
result = cursor.fetchone()
info['developer_name'] = result[0]
info['description'] = result[1]
return info
class FlossmoleProject():
id = 0
id_forge = 0
datasource_id = 0
name = ""
description = ""