@@ -117,14 +117,19 @@ def parse_options(args):
117
117
except PermissionError :
118
118
usage ("PASS required" )
119
119
120
+ def _deduplicate_list (items ):
121
+ """ Deduplicate a list while maintaining order by converting it to a dictionary and then back to a list.
122
+ Used to ensure a consistent ordering for output group lists, since sets are unordered.
123
+ """
124
+ return list (dict .fromkeys (items ))
120
125
121
126
def gid_pids_to_osguser_pid_gids (gid_pids , pid_osguser ):
122
- pid_gids = collections .defaultdict (set )
127
+ pid_gids = collections .defaultdict (list )
123
128
124
129
for gid in gid_pids :
125
130
for pid in gid_pids [gid ]:
126
- if pid_osguser [pid ] is not None :
127
- pid_gids [pid ].add (gid )
131
+ if pid_osguser [pid ] is not None and gid not in pid_gids [ pid ] :
132
+ pid_gids [pid ].append (gid )
128
133
129
134
return pid_gids
130
135
@@ -146,7 +151,7 @@ def get_osguser_groups(filter_group_name=None):
146
151
if filter_group_name is not None :
147
152
pid_gids = filter_by_group (pid_gids , groups , filter_group_name )
148
153
149
- return { pid_osguser [pid ]: set ( map (groups .get , gids ) )
154
+ return { pid_osguser [pid ]: map (groups .get , gids )
150
155
for pid , gids in pid_gids .items () }
151
156
152
157
@@ -157,9 +162,9 @@ def parse_localmap(inputfile):
157
162
# Split up 3 semantic columns
158
163
split_line = line .strip ().split (maxsplit = 2 )
159
164
if split_line [0 ] == "*" and len (split_line ) == 3 :
160
- line_groups = set ( re .split (r'[ ,]+' , split_line [2 ]) )
165
+ line_groups = re .split (r'[ ,]+' , split_line [2 ])
161
166
if split_line [1 ] in user_groupmap :
162
- user_groupmap [split_line [1 ]] |= line_groups
167
+ user_groupmap [split_line [1 ]] = _deduplicate_list ( user_groupmap [ split_line [ 1 ]] + line_groups )
163
168
else :
164
169
user_groupmap [split_line [1 ]] = line_groups
165
170
return user_groupmap
@@ -170,9 +175,9 @@ def merge_maps(maps):
170
175
for projectmap in maps :
171
176
for key in projectmap .keys ():
172
177
if key in merged_map :
173
- merged_map [key ] |= set ( projectmap [key ])
178
+ merged_map [key ] = _deduplicate_list ( merged_map [ key ] + projectmap [key ])
174
179
else :
175
- merged_map [key ] = set ( projectmap [key ])
180
+ merged_map [key ] = projectmap [key ]
176
181
return merged_map
177
182
178
183
0 commit comments