def show_cmd(fmt, series_id): """Show information about series. Retrieve Patchwork metadata for a series. """ LOG.debug('Showing series: id=%d', series_id) series = api.detail('series', series_id) def _format_submission(submission): return '%-4d %s' % (submission.get('id'), submission.get('name')) output = [ ('ID', series.get('id')), ('Date', series.get('date')), ('Name', series.get('name')), ('URL', series.get('web_url')), ('Submitter', '%s (%s)' % (series.get('submitter').get('name'), series.get('submitter').get('email'))), ('Project', series.get('project').get('name')), ('Version', series.get('version')), ('Received', '%d of %d' % (series.get('received_total'), series.get('total'))), ('Complete', series.get('received_all')), ('Cover', (_format_submission(series.get('cover_letter')) if series.get('cover_letter') else ''))] prefix = 'Patches' for patch in series.get('patches'): output.append((prefix, _format_submission(patch))) prefix = '' utils.echo(output, ['Property', 'Value'], fmt=fmt)
def _show_bundle(bundle, fmt): def _format_patch(patch): return '%-4d %s' % (patch.get('id'), patch.get('name')) output = [('ID', bundle.get('id')), ('Name', bundle.get('name')), ('URL', bundle.get('web_url')), ('Owner', bundle.get('owner').get('username')), ('Project', bundle.get('project').get('name')), ('Public', bundle.get('public'))] prefix = 'Patches' for patch in bundle.get('patches'): output.append((prefix, _format_patch(patch))) prefix = '' utils.echo(output, ['Property', 'Value'], fmt=fmt)
def _show_patch(patch, fmt): def _format_series(series): return '%-4d %s' % (series.get('id'), series.get('name') or '-') output = [('ID', patch.get('id')), ('Message ID', patch.get('msgid')), ('Date', patch.get('date')), ('Name', patch.get('name')), ('URL', patch.get('web_url')), ('Submitter', '%s (%s)' % (patch.get('submitter').get('name'), patch.get('submitter').get('email'))), ('State', patch.get('state')), ('Archived', patch.get('archived')), ('Project', patch.get('project').get('name')), ('Delegate', (patch.get('delegate').get('username') if patch.get('delegate') else '')), ('Commit Ref', patch.get('commit_ref'))] prefix = 'Series' for series in patch.get('series'): output.append((prefix, _format_series(series))) prefix = '' utils.echo(output, ['Property', 'Value'], fmt=fmt)
def show_cmd(fmt, bundle_id): """Show information about bundle. Retrieve Patchwork metadata for a bundle. """ LOG.debug('Showing bundle: id=%s', bundle_id) bundle = _get_bundle(bundle_id) def _format_patch(patch): return '%-4d %s' % (patch.get('id'), patch.get('name')) output = [('ID', bundle.get('id')), ('Name', bundle.get('name')), ('URL', bundle.get('web_url')), ('Owner', bundle.get('owner').get('username')), ('Project', bundle.get('project').get('name')), ('Public', bundle.get('public'))] prefix = 'Patches' for patch in bundle.get('patches'): output.append((prefix, _format_patch(patch))) prefix = '' utils.echo(output, ['Property', 'Value'], fmt=fmt)