Merge lp:~mwhudson/ubuntu-archive-scripts/team-report-yaml into lp:ubuntu-archive-scripts

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 235
Merged at revision: 235
Proposed branch: lp:~mwhudson/ubuntu-archive-scripts/team-report-yaml
Merge into: lp:ubuntu-archive-scripts
Diff against target: 107 lines (+44/-2)
2 files modified
generate-team-p-m (+43/-1)
run-proposed-migration (+1/-1)
To merge this branch: bzr merge lp:~mwhudson/ubuntu-archive-scripts/team-report-yaml
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
Sebastien Bacher Approve
Review via email: mp+361112@code.launchpad.net

Description of the change

This produces output like this: http://paste.ubuntu.com/p/QKpv9RVxN4/

I'm not sure who asked for this but we should ask them if this matches their expectations :)

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for working on that, we (desktop) requested to have that yaml, the output from that pastebin looks fine to me and the code seems fine as well, so giving a +1

review: Approve
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'generate-team-p-m'
--- generate-team-p-m 2018-09-11 21:26:25 +0000
+++ generate-team-p-m 2018-12-19 02:43:29 +0000
@@ -16,7 +16,7 @@
16# A copy of the GNU General Public License version 2 is in LICENSE.16# A copy of the GNU General Public License version 2 is in LICENSE.
1717
18import argparse18import argparse
19from collections import defaultdict19from collections import defaultdict, OrderedDict
20import datetime20import datetime
21import json21import json
22import os22import os
@@ -133,6 +133,31 @@
133 package_to_teams.setdefault(package, []).append(team)133 package_to_teams.setdefault(package, []).append(team)
134 return package_to_teams134 return package_to_teams
135135
136def setup_yaml():
137 """ http://stackoverflow.com/a/8661021 """
138 represent_dict_order = (
139 lambda self, data: self.represent_mapping('tag:yaml.org,2002:map',
140 data.items()))
141 yaml.add_representer(OrderedDict, represent_dict_order)
142
143
144setup_yaml()
145
146def as_data(inst):
147 r = OrderedDict()
148 fields = [field.name for field in attr.fields(type(inst))]
149 fields.extend(getattr(inst, "extra_fields", []))
150 for field in fields:
151 if field.startswith('_'):
152 continue
153 v = getattr(
154 inst,
155 'serialize_' + field,
156 lambda: getattr(inst, field))()
157 if v is not None:
158 r[field] = v
159 return r
160
136@attr.s161@attr.s
137class ArchRegression:162class ArchRegression:
138 arch = attr.ib(default=None)163 arch = attr.ib(default=None)
@@ -147,6 +172,9 @@
147 version = attr.ib(default=None) # version that regressed172 version = attr.ib(default=None) # version that regressed
148 arches = attr.ib(default=None) # [ArchRegression]173 arches = attr.ib(default=None) # [ArchRegression]
149174
175 def serialize_arches(self):
176 return [as_data(a) for a in self.arches]
177
150 @property178 @property
151 def package_version(self):179 def package_version(self):
152 return self.package + '/' + self.version180 return self.package + '/' + self.version
@@ -163,6 +191,11 @@
163191
164 _age = attr.ib(default=None)192 _age = attr.ib(default=None)
165193
194 extra_fields = ['age']
195
196 def serialize_regressions(self):
197 return [as_data(r) for r in self.regressions]
198
166 @property199 @property
167 def late(self):200 def late(self):
168 return self.age > 3201 return self.age > 3
@@ -173,6 +206,7 @@
173 return self._age206 return self._age
174 else:207 else:
175 return self.data["policy_info"]["age"]["current-age"]208 return self.data["policy_info"]["age"]["current-age"]
209
176 @age.setter210 @age.setter
177 def age(self, val):211 def age(self, val):
178 self._age = val212 self._age = val
@@ -193,6 +227,7 @@
193 parser.add_argument('--true-ages', action='store_true')227 parser.add_argument('--true-ages', action='store_true')
194 parser.add_argument('--excuses-yaml', action='store')228 parser.add_argument('--excuses-yaml', action='store')
195 parser.add_argument('output')229 parser.add_argument('output')
230 parser.add_argument('yaml_output', default=None)
196 args = parser.parse_args()231 args = parser.parse_args()
197232
198 components = args.components.split(',')233 components = args.components.split(',')
@@ -296,6 +331,13 @@
296 team_to_problems=team_to_problems,331 team_to_problems=team_to_problems,
297 team_to_attn_count=team_to_attn_count,332 team_to_attn_count=team_to_attn_count,
298 now=excuses["generated-date"].strftime("%Y.%m.%d %H:%M:%S")))333 now=excuses["generated-date"].strftime("%Y.%m.%d %H:%M:%S")))
334 if args.yaml_output:
335 team_to_problem_data = {}
336 for t, ps in team_to_problems.items():
337 team_to_problem_data[t] = [as_data(p) for p in ps]
338 with open(args.yaml_output, 'w', encoding='utf-8') as fp:
339 yaml.dump(team_to_problem_data, fp)
340
299341
300if __name__ == '__main__':342if __name__ == '__main__':
301 main()343 main()
302344
=== modified file 'run-proposed-migration'
--- run-proposed-migration 2018-10-30 11:14:50 +0000
+++ run-proposed-migration 2018-12-19 02:43:29 +0000
@@ -51,5 +51,5 @@
51 cd ~/public_html/proposed-migration/51 cd ~/public_html/proposed-migration/
52 generate-team-p-m --excuses-yaml $SERIES/update_excuses.yaml \52 generate-team-p-m --excuses-yaml $SERIES/update_excuses.yaml \
53 --subscribers-json ~/public_html/package-team-mapping.json \53 --subscribers-json ~/public_html/package-team-mapping.json \
54 $SERIES/update_excuses_by_team.html54 $SERIES/update_excuses_by_team.html $SERIES/update_excuses_by_team.yaml
55fi55fi

Subscribers

People subscribed via source and target branches