Skip to content

Commit 851abae

Browse files
authored
Merge pull request #10 from edquist/derorable
decommission the adorable rorable
2 parents 4f603c4 + 1ce9705 commit 851abae

File tree

4 files changed

+28
-51
lines changed

4 files changed

+28
-51
lines changed

.github/workflows/python-linters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Python 3.6
2323
uses: actions/setup-python@v2
2424
with:
25-
python-version: 3.6
25+
python-version: 3.6.15
2626

2727
- uses: actions/cache@v2
2828
with:
@@ -51,7 +51,7 @@ jobs:
5151
- name: Set up Python 3.6
5252
uses: actions/setup-python@v2
5353
with:
54-
python-version: 3.6
54+
python-version: 3.6.15
5555

5656
- uses: actions/cache@v2
5757
with:

create_project.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,32 +137,23 @@ def get_co_person_identifiers(pid):
137137

138138

139139
def get_co_group(gid):
140-
grouplist = call_api("co_groups/%s.json" % gid) | get_datalist("CoGroups")
140+
resp_data = call_api("co_groups/%s.json" % gid)
141+
grouplist = get_datalist(resp_data, "CoGroups")
141142
if not grouplist:
142143
raise RuntimeError("No such CO Group Id: %s" % gid)
143144
return grouplist[0]
144145

145146

146147
def get_identifier(id_):
147-
idfs = call_api("identifiers/%s.json" % id_) | get_datalist("Identifiers")
148+
resp_data = call_api("identifiers/%s.json" % id_)
149+
idfs = get_datalist(resp_data, "Identifiers")
148150
if not idfs:
149151
raise RuntimeError("No such Identifier Id: %s" % id_)
150152
return idfs[0]
151153

152154

153-
# @rorable
154-
# def foo(x): ...
155-
# x | foo -> foo(x)
156-
class rorable:
157-
def __init__(self, f): self.f = f
158-
def __call__(self, *a, **kw): return self.f(*a, **kw)
159-
def __ror__ (self, x): return self.f(x)
160-
161-
162-
def get_datalist(listname):
163-
def get(data):
164-
return data[listname] if data else []
165-
return rorable(get)
155+
def get_datalist(data, listname):
156+
return data[listname] if data else []
166157

167158

168159
# script-specific functions
@@ -191,7 +182,8 @@ def add_identifier_to_group(gid, type_, identifier_name):
191182

192183

193184
def gname_to_gid(gname):
194-
groups = get_osg_co_groups() | get_datalist("CoGroups")
185+
resp_data = get_osg_co_groups()
186+
groups = get_datalist(resp_data, "CoGroups")
195187
matching = [ g for g in groups if g["Name"] == gname ]
196188

197189
if len(matching) > 1:

group_fixup.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,15 @@ def get_co_person_identifiers(pid):
148148

149149

150150
def get_co_group(gid):
151-
grouplist = call_api("co_groups/%s.json" % gid) | get_datalist("CoGroups")
151+
resp_data = call_api("co_groups/%s.json" % gid)
152+
grouplist = get_datalist(resp_data, "CoGroups")
152153
if not grouplist:
153154
raise RuntimeError("No such CO Group Id: %s" % gid)
154155
return grouplist[0]
155156

156157

157-
# @rorable
158-
# def foo(x): ...
159-
# x | foo -> foo(x)
160-
class rorable:
161-
def __init__(self, f): self.f = f
162-
def __call__(self, *a, **kw): return self.f(*a, **kw)
163-
def __ror__ (self, x): return self.f(x)
164-
165-
166-
def get_datalist(listname):
167-
def get(data):
168-
return data[listname] if data else []
169-
return rorable(get)
158+
def get_datalist(data, listname):
159+
return data[listname] if data else []
170160

171161

172162
# api call results massagers
@@ -241,7 +231,8 @@ def show_misnamed_unixcluster_groups():
241231

242232

243233
def show_group_identifiers(gid):
244-
identifiers = get_co_group_identifiers(gid) | get_datalist("Identifiers")
234+
resp_data = get_co_group_identifiers(gid)
235+
identifiers = get_datalist(resp_data, "Identifiers")
245236
for i in identifiers:
246237
print(' - Identifier {Id}: ({Type}) "{Identifier}"'.format(**i))
247238

@@ -289,7 +280,8 @@ def fixup_unixcluster_group(gid):
289280
group = get_co_group(gid)
290281
oldname = group["Name"]
291282
newname = get_fixed_unixcluster_group_name(oldname)
292-
identifiers = get_co_group_identifiers(gid) | get_datalist("Identifiers")
283+
resp_data = get_co_group_identifiers(gid)
284+
identifiers = get_datalist(resp_data, "Identifiers")
293285
ids_to_delete = get_identifiers_to_delete(identifiers)
294286

295287
show_misnamed_unixcluster_group(group)

osg-comanage-project-usermap.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,44 +108,37 @@ def get_co_person_identifiers(pid):
108108
return call_api("identifiers.json", copersonid=pid)
109109

110110

111-
# @rorable
112-
# def foo(x): ...
113-
# x | foo -> foo(x)
114-
class rorable:
115-
def __init__(self, f): self.f = f
116-
def __call__(self, *a, **kw): return self.f(*a, **kw)
117-
def __ror__ (self, x): return self.f(x)
118-
119-
120-
def get_datalist(listname):
121-
def get(data):
122-
return data[listname] if data else []
123-
return rorable(get)
111+
def get_datalist(data, listname):
112+
return data[listname] if data else []
124113

125114

126115
# api call results massagers
127116

128117
def get_osg_co_groups__map():
129118
#print("get_osg_co_groups__map()")
130-
data = get_osg_co_groups() | get_datalist("CoGroups")
119+
resp_data = get_osg_co_groups()
120+
data = get_datalist(resp_data, "CoGroups")
131121
return { g["Id"]: g["Name"] for g in data }
132122

133123

134124
def co_group_is_ospool(gid):
135125
#print(f"co_group_is_ospool({gid})")
136-
data = get_co_group_identifiers(gid) | get_datalist("Identifiers")
126+
resp_data = get_co_group_identifiers(gid)
127+
data = get_datalist(resp_data, "Identifiers")
137128
return any( i["Type"] == "ospoolproject" for i in data )
138129

139130

140131
def get_co_group_members__pids(gid):
141132
#print(f"get_co_group_members__pids({gid})")
142-
data = get_co_group_members(gid) | get_datalist("CoGroupMembers")
133+
resp_data = get_co_group_members(gid)
134+
data = get_datalist(resp_data, "CoGroupMembers")
143135
return [ m["Person"]["Id"] for m in data ]
144136

145137

146138
def get_co_person_osguser(pid):
147139
#print(f"get_co_person_osguser({pid})")
148-
data = get_co_person_identifiers(pid) | get_datalist("Identifiers")
140+
resp_data = get_co_person_identifiers(pid)
141+
data = get_datalist(resp_data, "Identifiers")
149142
typemap = { i["Type"]: i["Identifier"] for i in data }
150143
return typemap.get("osguser")
151144

0 commit comments

Comments
 (0)