~nhandler/ubtls/return-correct-info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python

import sys
from ubtlib import UBTMethods
from ubtlib import UBTGlobals

beginners = UBTMethods.UBT()

def help():
	print "Usage: ubtlib <class> <args>"
	print "  Classes:"
	print "    owner         -- Lookup an owner's email address"
	print "      One argument, team name"
	print "    member_check  -- Check a user's membership in a team"
	print "      Two arguments, user, then team name"
	print "      One argument, username"
	print ""
	print ""
	print " Current Aliases:"

	for fg in UBTGlobals.UBT_FG:
		print "  " + fg
	print ""
	print ""

argc = len(sys.argv)

if argc > 1:
	args = sys.argv

	if args[1] == "owner" and argc > 2:
		# print "Owner of " + args[2]
		beginners.connect()
		beginners.getLeaderEmail( args[2] )

	elif args[1] == "member_check":
		if argc > 3:
			beginners.connect()
			beginners.isMember( args[2], args[3] )
		elif argc > 2:
			beginners.connect()
			beginners.isMember( args[2], "self" )
		else:
			help()
	else:
		help()
else:
	help()