MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / role_name_for_user_id

Function role_name_for_user_id

paperflow/roles.py:48–64  ·  view source on GitHub ↗

Return the user-facing role name for a user id, or the user id itself.

(user_id: str, *, project_root: Optional[Path] = None)

Source from the content-addressed store, hash-verified

46def load_roles_meta(*, project_root: Optional[Path] = None) -> Dict[str, Any]:
47 path = roles_path(project_root=project_root)
48 try:
49 data = json.loads(path.read_text(encoding="utf-8"))
50 except (OSError, json.JSONDecodeError):
51 return {"roles": {}, "current_role": None}
52 return data if isinstance(data, dict) else {"roles": {}, "current_role": None}
53
54
55def role_name_for_user_id(user_id: str, *, project_root: Optional[Path] = None) -> str:
56 """Return the user-facing role name for a user id, or the user id itself."""
57 cleaned_user_id = str(user_id or "").strip()
58 if not cleaned_user_id:
59 return ""
60
61 roles = load_roles_meta(project_root=project_root).get("roles") or {}
62 if not isinstance(roles, dict):
63 return cleaned_user_id
64
65 for role_name, role_info in roles.items():
66 if not isinstance(role_info, dict):
67 continue

Callers 1

Calls 2

getMethod · 0.80
load_roles_metaFunction · 0.70

Tested by

no test coverage detected