00001
00002
00003
00004 DISTRO='electric'
00005
00006 import codecs
00007 import math
00008 import collections
00009 from operator import itemgetter
00010
00011 from ros import rosdistro
00012 import roslib.manifest
00013 import roslib.stacks
00014
00015 NUM_COLS = 4
00016
00017 def get_distro():
00018 uri = rosdistro.distro_uri(DISTRO)
00019 return rosdistro.Distro(uri)
00020
00021 def get_stacks(distro, common=True):
00022 """
00023 @param: restrict stack list to 'common' (robot-generic) stacks
00024 """
00025 stacks = []
00026 if common:
00027
00028 variants = ['desktop-full', 'robot', 'move-arm']
00029 for v in variants:
00030 stacks.extend(distro.variants[v].stack_names)
00031 core_drivers = ['camera_drivers', 'laser_drivers', 'imu_drivers', 'sound_drivers', 'joystick_drivers']
00032 stacks.extend(core_drivers)
00033 else:
00034 stacks = distro.released_stacks.keys()[:]
00035 available = roslib.stacks.list_stacks()
00036 stacks = [s for s in stacks if s in available]
00037 for s in stacks:
00038 if 'experimental' in s:
00039 stacks.remove(s)
00040 return stacks
00041
00042 def expand_to_packages(stacks):
00043 packages = []
00044 for s in stacks:
00045 val = roslib.stacks.packages_of(s)
00046 packages.extend(roslib.stacks.packages_of(s))
00047
00048
00049
00050
00051 ignore = ['cwiid', 'spacenav', 'wxpropgrid', 'bullet', 'xmlrpcpp', 'opende', 'opencv2', 'pcl', 'ogre', 'ogre_tools', 'eigen', 'assimp', 'tinyxml', 'yaml_cpp', 'cminpack', 'flann', 'gmapping', 'colladadom', 'convex_decomposition', 'ivcon', 'bfl', 'wxPython_swig_interface', 'wxswig', 'xdot']
00052 return list(set(packages) - set(ignore))
00053
00054 name_map = {
00055 u'Brian Gerkey': u'Brian P. Gerkey',
00056 u'Ioan Sucan': u'Ioan A. Sucan',
00057 u'Kenneth Conley': u'Ken Conley',
00058 u'DerekKing': u'Derek King',
00059 u'John': u'John Hsu',
00060 u'Stu Glaser': u'Stuart Glaser',
00061 u'Lorenz Mosenlechner': u'Lorenz Mösenlechner',
00062 u'Lorenz Moesenlechner': u'Lorenz Mösenlechner',
00063 }
00064 def normalize_name(name):
00065 name = name.split(u'/')[0]
00066 name = name.split(u'(')[0]
00067 name = name.strip()
00068 s = name.split(u' ')
00069 name = u' '.join([x for x in s if not '@' in x])
00070
00071 wrapped = [u'inc.', u'modifications', u'maintained by', u'wrapping',
00072 u'ported',
00073 u'wrapper', u'contributions', u'except ', u'et al', u'extended']
00074 for w in wrapped:
00075 if w in name.lower():
00076 return None
00077 if u'ROS ' in name:
00078 return None
00079 if name in name_map:
00080 return name_map[name]
00081
00082 if len(name.split(' ')) == 1:
00083 return None
00084 return name
00085
00086 def _count_authors(packages):
00087 ignore = [None,
00088 'Orocos Developers', 'Prosilica', 'Various', 'many others',
00089 'Personal Networks', 'RTT Developers', 'OCL Development Team',
00090 'Apache Foundation', 'Austin Robot Technology', 'mil1pal',
00091 'Many',
00092 'Damien Douxchamps', 'Dan Dennedy',
00093 'Richard Vaughan', 'Andrew Howard',
00094 ]
00095 authors = collections.defaultdict(int)
00096 for p in set(packages):
00097 if 'test_' in p or p.startswith('pr2_') or p.startswith('wge100'):
00098 continue
00099 m = roslib.manifest.load_manifest(p)
00100 author_names = []
00101 for n in m.author.split(u','):
00102 author_names.extend(n.split(u' and '))
00103 for name in set(normalize_name(x) for x in author_names):
00104 if name and name not in ignore:
00105 authors[name] += 1
00106
00107
00108 authors = sorted([(k, v) for (k, v) in authors.iteritems()], key=itemgetter(0))
00109 return authors
00110
00111 def count_authors(common=True):
00112 stacks = get_stacks(get_distro(), common)
00113 packages = expand_to_packages(stacks)
00114 authors = _count_authors(packages)
00115 return authors
00116
00117 def get_extended_authors(core_authors, all_authors):
00118 core_authors = dict(core_authors)
00119 extended_authors = dict(all_authors)
00120 for k in core_authors:
00121 if k in extended_authors:
00122 del extended_authors[k]
00123 return sorted([(k, v) for (k, v) in extended_authors.iteritems() if v], key=itemgetter(0))
00124
00125 def create_html():
00126 core_authors = count_authors(True)
00127 all_authors = count_authors(False)
00128
00129 extended_authors = get_extended_authors(core_authors, all_authors)
00130
00131 contributors = get_contributors()
00132 c2 = []
00133 author_names = [x[0] for x in all_authors]
00134 for c in contributors:
00135 if c not in author_names:
00136 c2.append(c)
00137
00138 contributors = sorted(c2)
00139
00140 core_author_names_f = [u"%s"%(k) for (k, v) in core_authors]
00141 extended_author_names_f = [u"%s"%(k) for (k, v) in extended_authors]
00142 text = u'<table border="0">'+\
00143 to_html(core_author_names_f, title="Core Authors (ROS Desktop Full)")+\
00144 to_html(extended_author_names_f, title="Extended Authors (Released Stacks)")+\
00145 to_html(contributors, title=u'Contributors')+\
00146 u'</table>'
00147 return HTML_TMPL%(text)
00148
00149 if 0:
00150 HTML_TMPL = """<html>
00151 <head>
00152 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
00153 <title>ROS Contributors</title>
00154 </head>
00155 <body>
00156
00157 %s
00158
00159 </body>
00160 </html>"""
00161 else:
00162 HTML_TMPL = "%s"
00163
00164 def to_html(authors, title=u'Authors'):
00165 l = len(authors)
00166 count = 0
00167 cols = []
00168 text = ''
00169 col_length = int(math.ceil(float(len(authors)) / NUM_COLS))
00170 for i, name in enumerate(authors):
00171 if i % col_length == 0 and i > 0:
00172 cols.append(text)
00173 text = ''
00174 text = text + u'\n' + name + u'<br />'
00175 if text:
00176 cols.append(text)
00177 html = u'<tr><th colspan="%s">%s</th></tr>'%(col_length, title)+\
00178 u'<tr valign="top">\n' + u'\n'.join([u'<td>%s</td>'%(c) for c in cols]) + u'\n</tr>'
00179 return html
00180
00181 def get_contributors(filename='contributors.txt'):
00182 with codecs.open(filename, 'r', encoding='utf-8') as f:
00183 return [x.strip() for x in f.readlines() if x.strip()]
00184
00185 if __name__ == '__main__':
00186 text = create_html()
00187 with open('contributors.html', 'w') as f:
00188 f.write(text.encode('utf-8'))