Skip to content

Commit

Permalink
Remove some new lines from PR description & small refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
beyhan authored and ameowlia committed Jul 9, 2024
1 parent 1bdffa7 commit 8965767
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions org/org_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ def get_contributors(self) -> Set[str]:
return set(self.contributors)

def get_community_members_with_role_by_wg(self) -> Dict[str, Set[str]]:
result = dict()
result["toc"] = set(self.toc)
result = {"toc": set(self.toc)}
for wg in self.working_groups:
result[wg["name"]] = OrgGenerator._wg_github_users(wg)
return result
Expand Down
23 changes: 11 additions & 12 deletions org/org_user_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def _write_yaml_file(self, path, data):
yaml.dump(data, f)

def _get_inactive_users_msg_for_wgs(self, inactive_users_by_wg, user_tagging_prefix):
result = "" if len(inactive_users_by_wg.keys()) == 0 else "\n\nWarning:\n"
for wg in inactive_users_by_wg.keys():
wg_users_as_list = "\n".join(str(user_tagging_prefix + s) for s in inactive_users_by_wg[wg])
result = "\n\nWarning:\n" if inactive_users_by_wg else ""
for wg, users in inactive_users_by_wg.items():
wg_users_as_list = "\n".join(str(user_tagging_prefix + s) for s in users)
result += f'Inactive users of Working Group "{wg}" are: \n{wg_users_as_list}\n'
return result

Expand Down Expand Up @@ -121,20 +121,19 @@ def get_inactive_users_msg(self, users_to_delete, inactive_users_by_wg, tagusers
return (
f"According to the rules for inactivity defined in [RFC-0025]({rfc}) following users will be deleted:\n"
f"{users_as_list}\nAccording to the [revocation policy in the RFC]({rfc_revocation_rules}), users have"
" two weeks to refute this revocation, if they wish by commenting on this pull-request\n"
" two weeks to refute this revocation, if they wish by commenting on this pull-request "
"and open a new pull-request to be re-added as contributor after this one is merged.\n"
f"As alternative, if you are active in a working group please check the [promotion rules]({rfc_promotion_rules})\n"
f"As alternative, if you are active in a working group please check the [promotion rules]({rfc_promotion_rules}) "
"and if you are eligible and wish apply for a role in that working group."
f"{self._get_inactive_users_msg_for_wgs(inactive_users_by_wg, user_tagging_prefix)}"
)

def get_inactive_users_by_wg(self, community_members_with_role_by_wg):
def get_inactive_users_by_wg(self, inactive_users, community_members_with_role_by_wg):
result = dict()
for wg in community_members_with_role_by_wg.keys():
wg_members = community_members_with_role_by_wg[wg]
wg_inactive_users = inactive_users.intersection(wg_members)
if len(wg_inactive_users) != 0 and wg != "Admin":
result[wg] = wg_inactive_users
for wg, members in community_members_with_role_by_wg.items():
wg_inactive_members = inactive_users.intersection(members)
if len(wg_inactive_members) != 0 and wg != "Admin":
result[wg] = wg_inactive_members
return result

@staticmethod
Expand Down Expand Up @@ -181,7 +180,7 @@ def _get_bool_env_var(env_var_name, default):
print(f"Inactive users length is {len(inactive_users)} and inactive users are {inactive_users}")
users_to_delete = inactive_users - community_members_with_role
tagusers = args.tagusers or InactiveUserHandler._get_bool_env_var("INACTIVE_USER_MANAGEMENT_TAG_USERS", "False")
inactive_users_by_wg = userHandler.get_inactive_users_by_wg(community_members_with_role_by_wg)
inactive_users_by_wg = userHandler.get_inactive_users_by_wg(inactive_users, community_members_with_role_by_wg)
inactive_users_msg = userHandler.get_inactive_users_msg(users_to_delete, inactive_users_by_wg, tagusers)
if args.dryrun or InactiveUserHandler._get_bool_env_var("INACTIVE_USER_MANAGEMENT_DRY_RUN", "False"):
print(f"Dry-run mode.\nInactive_users_msg is: {inactive_users_msg}")
Expand Down

0 comments on commit 8965767

Please sign in to comment.