def _generate_teams_badges(app): all_teams = projects.get_project_data() files = [] badges_dir = os.path.join(app.outdir, 'badges') if not os.path.exists(badges_dir): os.mkdir(badges_dir) filename = os.path.join(badges_dir, 'project-unofficial.svg') svg_data = _generate_badge('project', 'unofficial', colorscheme='red') svg = FLAT_BADGE_TEMPLATE.format(**svg_data).encode('utf-8') with open(filename, 'w') as f: f.write(SVG_ROOT.format(height=20, width=106, svg=svg)) files.append(filename) for team, info in all_teams.items(): app.info('generating team badge for %s' % team) for name, deliverable in info['deliverables'].items(): tags = info.get('tags', []) + deliverable.get('tags', []) badges = _organize_badges(_generate_tag_badges(tags)) svg = '\n'.join(_to_svg(chain(*badges))) root_width = badges[-1][-1]['svg_x'] + badges[-1][-1]['width'] root_height = badges[-1][0]['svg_y'] + badges[-1][0]['height'] for repo in deliverable.get('repos', []): repo_name = repo.split('/')[1] filename = os.path.join(badges_dir, '%s.svg' % projects.slugify(repo_name)) with open(filename, 'w') as f: f.write(SVG_ROOT.format(height=root_height, width=root_width, svg=svg)) files.append(filename) return files
def _build_projects_by_tag(): for proj_name, info in projects.get_project_data().items(): for tag in info.get('tags', []): l = _projects_by_tag.setdefault(tag, []) l.append((proj_name, None)) for name, deliverable in info.get('deliverables', {}).items(): for tag in deliverable.get('tags', []): l = _projects_by_tag.setdefault(tag, []) l.append((proj_name, name))
def _write_team_pages(app): all_teams = projects.get_project_data() files = [] for team, info in all_teams.items(): slug = projects.slugify(team) filename = 'reference/projects/%s.rst' % slug app.info('generating team page for %s' % team) with open(filename, 'w') as f: f.write('\n'.join(_team_to_rst(team, info))) files.append(filename) return files
def _write_team_pages(app): all_teams = projects.get_project_data() files = [] for team, info in all_teams.items(): slug = projects.slugify(team) filename = 'reference/projects/%s.rst' % slug app.info('generating team page for %s' % team) with open(filename, 'w', encoding='utf-8') as f: f.write('\n'.join(_team_to_rst(team, info))) files.append(filename) return files
def run(self): project = self.options.get('project') if not project: error = self.state_machine.reporter.error( 'No project set for extra-atcs table', nodes.literal_block(self.block_text, self.block_text), line=self.lineno) return [error] # Handle the width settings and title try: col_widths = self.get_column_widths(len(self.HEADERS)) title, messages = self.make_title() except SystemMessagePropagation as detail: return [detail.args[0]] except Exception as err: error = self.state_machine.reporter.error( 'Error processing memberstable directive:\n%s' % err, nodes.literal_block(self.block_text, self.block_text), line=self.lineno, ) return [error] all_teams = projects.get_project_data() try: team_data = all_teams[project] except KeyError: raise ValueError('No project %r in projects.yaml' % (project, )) project_members = team_data.get('extra-atcs', []) # If we have no extra ATCs, skip building the table. if not project_members: return [] # Sort the project_members by name project_members = sorted( project_members, key=operator.itemgetter('name'), ) table_node = self.build_table(project_members, col_widths) table_node['classes'] += self.options.get('class', []) self.add_name(table_node) if title: table_node.insert(0, title) return [table_node] + messages
def run(self): project = self.options.get('project') if not project: error = self.state_machine.reporter.error( 'No project set for extra-atcs table', nodes.literal_block(self.block_text, self.block_text), line=self.lineno) return [error] # Handle the width settings and title try: col_widths = self.get_column_widths(len(self.HEADERS)) title, messages = self.make_title() except SystemMessagePropagation as detail: return [detail.args[0]] except Exception as err: error = self.state_machine.reporter.error( 'Error processing memberstable directive:\n%s' % err, nodes.literal_block(self.block_text, self.block_text), line=self.lineno, ) return [error] all_teams = projects.get_project_data() try: team_data = all_teams[project] except KeyError: raise ValueError('No project %r in projects.yaml' % (project,)) project_members = team_data.get('extra-atcs', []) # If we have no extra ATCs, skip building the table. if not project_members: return [] # Sort the project_members by name project_members = sorted( project_members, key=operator.itemgetter('name'), ) table_node = self.build_table(project_members, col_widths) table_node['classes'] += self.options.get('class', []) self.add_name(table_node) if title: table_node.insert(0, title) return [table_node] + messages
def run(self): all_teams = projects.get_project_data() # Build the view of the data to be parsed for rendering. result = ViewList() for team_name in sorted(all_teams.keys()): team_info = all_teams[team_name] for line in _team_to_rst(team_name, team_info): result.append(line, '<' + __name__ + '>') # Parse what we have into a new section. node = nodes.section() node.document = self.state.document nested_parse_with_titles(self.state, result, node) return node.children
def run(self): all_teams = projects.get_project_data() # Build the view of the data to be parsed for rendering. result = statemachine.ViewList() for team_name in sorted(all_teams.keys()): team_info = all_teams[team_name] for line in _team_to_rst(team_name, team_info): result.append(line, '<' + __name__ + '>') # Parse what we have into a new section. node = nodes.section() node.document = self.state.document nested_parse_with_titles(self.state, result, node) return node.children
def _generate_teams_badges(app, exception=None): LOG.info('Generating team badges') all_teams = projects.get_project_data() files = [] badges_dir = os.path.join(app.outdir, 'badges') if not os.path.exists(badges_dir): os.mkdir(badges_dir) filename = os.path.join(badges_dir, 'project-unofficial.svg') svg_data = _generate_badge('project', 'unofficial', colorscheme='red') svg = FLAT_BADGE_TEMPLATE.format(**svg_data) with open(filename, 'w', encoding='utf-8') as f: f.write(SVG_ROOT.format(height=20, width=106, svg=svg)) files.append(filename) for team, info in all_teams.items(): LOG.info('generating team badge for %s' % team) for name, deliverable in info['deliverables'].items(): tags = info.get('tags', []) + deliverable.get('tags', []) badges = _organize_badges(_generate_tag_badges(tags)) svg = '\n'.join(_to_svg(chain(*badges))) root_width = max([bdg_row[-1]['width'] + bdg_row[-1]['svg_x'] for bdg_row in badges]) root_height = badges[-1][0]['svg_y'] + badges[-1][0]['height'] for repo in deliverable.get('repos', []): repo_name = repo.split('/')[1] filename = os.path.join(badges_dir, '%s.svg' % projects.slugify(repo_name)) with open(filename, 'w') as f: f.write(SVG_ROOT.format(height=root_height, width=root_width, svg=svg)) files.append(filename) return files
# Handle the width settings and title try: col_widths = self.get_column_widths(len(self.HEADERS)) title, messages = self.make_title() except SystemMessagePropagation, detail: return [detail.args[0]] except Exception, err: error = self.state_machine.reporter.error( 'Error processing memberstable directive:\n%s' % err, nodes.literal_block(self.block_text, self.block_text), line=self.lineno, ) return [error] all_teams = projects.get_project_data() try: team_data = all_teams[project] except KeyError: raise ValueError('No project %r in projects.yaml' % (project, )) project_members = team_data.get('extra-atcs', []) # If we have no extra ATCs, skip building the table. if not project_members: return [] # Sort the project_members by name project_members = sorted( project_members, key=operator.itemgetter('name'), )
def get(self): self.response.headers['Content-Type'] = 'application/json' self.write(json.dumps(get_project_data()))