Skip to content

Commit 4999af2

Browse files
committed
remove unused stuff from osg-comanage-project-usermap (SOFTWARE-5057)
1 parent dd5540a commit 4999af2

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

group_fixup.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
-f passfile specify path to file to open and read PASS
3030
-e ENDPOINT specify REST endpoint
3131
(default = {ENDPOINT})
32-
-o outfile specify output file (default: write to stdout)
3332
-h display this help text
3433
3534
PASS for USER is taken from the first of:
@@ -51,7 +50,6 @@ class Options:
5150
endpoint = ENDPOINT
5251
user = "co_8.project_script"
5352
osg_co_id = OSG_CO_ID
54-
outfile = None
5553
authstr = None
5654

5755

@@ -147,29 +145,12 @@ def get(data):
147145

148146
# api call results massagers
149147

150-
def get_osg_co_groups__map():
151-
#print("get_osg_co_groups__map()")
152-
data = get_osg_co_groups() | get_datalist("CoGroups")
153-
return { g["Id"]: g["Name"] for g in data }
154148

155149

156-
def co_group_is_ospool(gid):
157-
#print(f"co_group_is_ospool({gid})")
158-
data = get_co_group_identifiers(gid) | get_datalist("Identifiers")
159-
return any( i["Type"] == "ospoolproject" for i in data )
160150

161151

162-
def get_co_group_members__pids(gid):
163-
#print(f"get_co_group_members__pids({gid})")
164-
data = get_co_group_members(gid) | get_datalist("CoGroupMembers")
165-
return [ m["Person"]["Id"] for m in data ]
166152

167153

168-
def get_co_person_osguser(pid):
169-
#print(f"get_co_person_osguser({pid})")
170-
data = get_co_person_identifiers(pid) | get_datalist("Identifiers")
171-
typemap = { i["Type"]: i["Identifier"] for i in data }
172-
return typemap.get("osguser")
173154

174155

175156
def parse_options(args):
@@ -191,53 +172,16 @@ def parse_options(args):
191172
if op == '-d': passfd = int(arg)
192173
if op == '-f': passfile = arg
193174
if op == '-e': options.endpoint = arg
194-
if op == '-o': options.outfile = arg
195175

196176
user, passwd = getpw(options.user, passfd, passfile)
197177
options.authstr = mkauthstr(user, passwd)
198178

199179

200-
def gid_pids_to_osguser_pid_gids(gid_pids, pid_osguser):
201-
pid_gids = collections.defaultdict(set)
202-
203-
for gid in gid_pids:
204-
for pid in gid_pids[gid]:
205-
if pid_osguser[pid] is not None:
206-
pid_gids[pid].add(gid)
207-
208-
return pid_gids
209-
210-
211-
def get_osguser_groups():
212-
groups = get_osg_co_groups__map()
213-
ospool_gids = filter(co_group_is_ospool, groups)
214-
gid_pids = { gid: get_co_group_members__pids(gid) for gid in ospool_gids }
215-
all_pids = set( pid for gid in gid_pids for pid in gid_pids[gid] )
216-
pid_osguser = { pid: get_co_person_osguser(pid) for pid in all_pids }
217-
pid_gids = gid_pids_to_osguser_pid_gids(gid_pids, pid_osguser)
218-
219-
return { pid_osguser[pid]: sorted(map(groups.get, gids))
220-
for pid, gids in pid_gids.items() }
221-
222-
223-
def print_usermap_to_file(osguser_groups, file):
224-
for osguser, groups in sorted(osguser_groups.items()):
225-
print("* {} {}".format(osguser, ",".join(groups)), file=file)
226-
227-
228-
def print_usermap(osguser_groups):
229-
if options.outfile:
230-
with open(options.outfile, "w") as w:
231-
print_usermap_to_file(osguser_groups, w)
232-
else:
233-
print_usermap_to_file(osguser_groups, sys.stdout)
234180

235181

236182
def main(args):
237183
parse_options(args)
238184

239-
osguser_groups = get_osguser_groups()
240-
print_usermap(osguser_groups)
241185

242186

243187
if __name__ == "__main__":

0 commit comments

Comments
 (0)