← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-list-team-members into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-list-team-members into launchpad:master.

Commit message:
Port list-team-members to Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/397326

We can handle Unicode issues in the wrapper script, rather than artificially replacing non-ASCII characters in display names.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-list-team-members into launchpad:master.
diff --git a/lib/lp/registry/scripts/listteammembers.py b/lib/lp/registry/scripts/listteammembers.py
index 058ca8c..f9631c3 100644
--- a/lib/lp/registry/scripts/listteammembers.py
+++ b/lib/lp/registry/scripts/listteammembers.py
@@ -72,7 +72,7 @@ def process_team(teamname, display_option='simple'):
             name=member.name,
             teamname=teamname,
             id=member.id,
-            displayname=member.displayname.encode("ascii", "replace"),
+            displayname=member.displayname,
             ubuntite=ubuntite,
             sshkey=sshkey,
             )
diff --git a/scripts/list-team-members b/scripts/list-team-members
index 99b75ca..fcc8948 100755
--- a/scripts/list-team-members
+++ b/scripts/list-team-members
@@ -10,12 +10,12 @@ import _pythonpath
 import logging
 import sys
 
+import six
+
 from lp.registry.scripts.listteammembers import (
     NoSuchTeamError,
     process_team,
     )
-from lp.services.config import config
-from lp.services.scripts import execute_zcml_for_scripts
 from lp.services.scripts.base import (
     LaunchpadScript,
     LaunchpadScriptFailure,
@@ -56,9 +56,11 @@ class ListTeamMembersScript(LaunchpadScript):
                 member_details.update(process_team(teamname, display_option))
             except NoSuchTeamError:
                 raise LaunchpadScriptFailure("No such team: %s" % teamname)
-        print "\n".join(detail.encode('utf-8') for detail in
-                        sorted(member_details))
+        for detail in sorted(member_details):
+            print(six.ensure_str(detail))
+
 
 if __name__ == '__main__':
-    script = ListTeamMembersScript('lp.services.scripts.listteammembers', dbuser='listteammembers')
+    script = ListTeamMembersScript(
+        'lp.services.scripts.listteammembers', dbuser='listteammembers')
     script.run()