llvm.org GIT mirror llvm / 216b290
Avoid UnicodeEncodeError on non-ascii reviewer names ... by using unicode instead of byte strings where non-ascii strings can be formatted in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334098 91177308-0d34-0410-b5e6-96231b3b80d8 Kristof Beyls 1 year, 4 months ago
1 changed file(s) with 13 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
394394 print(msg)
395395
396396 newest_reviews = get_most_recent_reviews(days)
397 add_msg("These are the reviews that look interesting to be reviewed. " +
398 "The report below has 2 sections. The first " +
399 "section is organized per review; the second section is organized "
400 + "per potential reviewer.\n")
397 add_msg(u"These are the reviews that look interesting to be reviewed. " +
398 u"The report below has 2 sections. The first " +
399 u"section is organized per review; the second section is organized "
400 + u"per potential reviewer.\n")
401401 oldest_review = newest_reviews[-1] if len(newest_reviews) > 0 else None
402402 oldest_datetime = \
403403 datetime.fromtimestamp(oldest_review.dateModified) \
404404 if oldest_review else None
405 add_msg(("The report below is based on analyzing the reviews that got " +
406 "touched in the past {0} days (since {1}). " +
407 "The script found {2} such reviews.\n").format(
405 add_msg((u"The report below is based on analyzing the reviews that got " +
406 u"touched in the past {0} days (since {1}). " +
407 u"The script found {2} such reviews.\n").format(
408408 days, oldest_datetime, len(newest_reviews)))
409409 reviewer2reviews_and_scores = {}
410410 for i, review in enumerate(newest_reviews):
412412 matched_reviewers = filter_reviewers(matched_reviewers)
413413 if len(matched_reviewers) == 0:
414414 continue
415 add_msg(("{0:>3}. https://reviews.llvm.org/D{1} by {2}\n {3}\n" +
416 " Last updated on {4}").format(
415 add_msg((u"{0:>3}. https://reviews.llvm.org/D{1} by {2}\n {3}\n" +
416 u" Last updated on {4}").format(
417417 i, review.id,
418418 get_real_name_from_author(review.author), review.title,
419419 datetime.fromtimestamp(review.dateModified)))
420420 for reviewer, scores in matched_reviewers:
421 add_msg(" potential reviewer {0}, score {1}".format(
421 add_msg(u" potential reviewer {0}, score {1}".format(
422422 reviewer,
423423 "(" + "/".join(["{0:.1f}%".format(s) for s in scores]) + ")"))
424424 if reviewer not in reviewer2reviews_and_scores:
429429 for reviewer in sorted(reviewer2reviews_and_scores.keys()):
430430 reviews_and_scores = reviewer2reviews_and_scores[reviewer]
431431 reviews_and_scores.sort(key=lambda rs: rs[1], reverse=True)
432 add_msg("\n\nSUMMARY FOR {0} (found {1} reviews):".format(
432 add_msg(u"\n\nSUMMARY FOR {0} (found {1} reviews):".format(
433433 reviewer, len(reviews_and_scores)))
434434 for review, scores in reviews_and_scores:
435 add_msg("[{0}] https://reviews.llvm.org/D{1} '{2}' by {3}".format(
435 add_msg(u"[{0}] https://reviews.llvm.org/D{1} '{2}' by {3}".format(
436436 "/".join(["{0:.1f}%".format(s) for s in scores]), review.id,
437437 review.title, get_real_name_from_author(review.author)))
438438 return "\n".join(msgs)
538538 # Show progress, as this is a slow operation:
539539 sys.stdout.write('.')
540540 sys.stdout.flush()
541 logging.debug("matched_reviewers: {0}".format(matched_reviewers))
541 logging.debug(u"matched_reviewers: {0}".format(matched_reviewers))
542542 return matched_reviewers
543543
544544