Merge lp:~jelmer/lptools/check-membership into lp:lptools

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 37
Merged at revision: 37
Proposed branch: lp:~jelmer/lptools/check-membership
Merge into: lp:lptools
Diff against target: 87 lines (+78/-0)
2 files modified
bin/lp-check-membership (+57/-0)
doc/lp-check-membership.1 (+21/-0)
To merge this branch: bzr merge lp:~jelmer/lptools/check-membership
Reviewer Review Type Date Requested Status
Martin Pool Approve
lptools Hackers Pending
Review via email: mp+93709@code.launchpad.net

Description of the change

Import lp-check-membership from lp:hydrazine.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

    vote approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'bin/lp-check-membership'
2--- bin/lp-check-membership 1970-01-01 00:00:00 +0000
3+++ bin/lp-check-membership 2012-02-18 23:49:17 +0000
4@@ -0,0 +1,57 @@
5+#! /usr/bin/python
6+#
7+# Copyright (C) 2009 Canonical Ltd
8+
9+# lp-check-membership is free software; you can redistribute it and/or modify it
10+# under the terms of the GNU General Public License as published by the
11+# Free Software Foundation; either version 3, or (at your option) any
12+# later version.
13+#
14+# lp-check-membership is distributed in the hope that it will be useful, but
15+# WITHOUT ANY WARRANTY; without even the implied warranty of
16+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+# General Public License for more details.
18+#
19+# You should have received a copy of the GNU General Public License
20+# along with lp-check-membership; see the file COPYING. If not, write to the Free
21+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22+# 02110-1301, USA.
23+#
24+# Authors:
25+# Martin Pool
26+
27+"""lp-check-membership: Check whether a user is a member of a team.
28+
29+example: lp-check-membership mbp bzr
30+
31+Part of lptools <https://launchpad.net/lptools/>
32+"""
33+
34+
35+import optparse
36+import sys
37+
38+from lptools import config
39+
40+
41+def main(argv):
42+ parser = optparse.OptionParser('%prog [options] PERSON GROUP')
43+ opts, args = parser.parse_args()
44+ if len(args) != 2:
45+ print __doc__
46+ return 2
47+ user_name = args[0]
48+ group_name = args[1]
49+ lp = config.get_launchpad("check-membership")
50+ user = lp.people[user_name]
51+ for user_team in user.super_teams:
52+ if user_team.name == group_name:
53+ print '%s is a member of %s' % (user_name, group_name)
54+ return 0
55+ else:
56+ print '%s is not a member of %s' % (user_name, group_name)
57+ return 1
58+
59+
60+if __name__ == '__main__':
61+ sys.exit(main(sys.argv))
62
63=== added file 'doc/lp-check-membership.1'
64--- doc/lp-check-membership.1 1970-01-01 00:00:00 +0000
65+++ doc/lp-check-membership.1 2012-02-18 23:49:17 +0000
66@@ -0,0 +1,21 @@
67+.TH lp-check-membership "1" "Feb 19 2012" "lptools"
68+.SH NAME
69+lp-check-membership \- check if a launchpad user is a member of a group
70+
71+.SH SYNOPSIS
72+.B lp-check-membership <\fIperson\fR> <\fIgroup\fR>
73+.br
74+.B lp-check-membership \-\-help
75+
76+.SH DESCRIPTION
77+\fBlp-check-membership\fR checks if a user is a member of a particular
78+Launchpad group.
79+
80+.SH OPTIONS
81+Listed below are the command line options for \fBlp-check-membership\fR:
82+.TP
83+.BR \-h ", " \-\-help
84+Display a help message and exit.
85+
86+.SH AUTHORS
87+\fBlp-check-membership\fR was written by Martin Pool.

Subscribers

People subscribed via source and target branches