profiler_combine. Route handler or application helper. This docstring was expanded to make future maintenance easier. Returns: Varies.
()
| 16059 | |
| 16060 | Internal helper function. |
| 16061 | |
| 16062 | This docstring was added automatically to improve maintainability. |
| 16063 | |
| 16064 | Args: |
| 16065 | optional_enc: Parameter. |
| 16066 | |
| 16067 | Returns: |
| 16068 | Varies. |
| 16069 | """ |
| 16070 | if not optional_enc: |
| 16071 | return {} |
| 16072 | try: |
| 16073 | raw = aesgcm_decrypt_text(optional_enc) |
| 16074 | data = json.loads(raw) if raw else {} |
| 16075 | if isinstance(data, dict): |
| 16076 | # keep only known keys, but don't break older/newer |
| 16077 | return {k: str(v) for k, v in data.items() if v is not None} |
| 16078 | return {} |
| 16079 | except Exception: |
| 16080 | return {} |
| 16081 | |
| 16082 | # --------------------------- |
| 16083 | # Auto-sync: My Profile -> Profiler (per-user, encrypted) |
| 16084 | # --------------------------- |
| 16085 | |
| 16086 | _AUTOSYNC_TYPE = "user_profile" |
| 16087 | |
| 16088 | def _split_name_from_nick(nick: str, fallback_last: str) -> Tuple[str, str]: |
| 16089 | """Split a nickname into first/last. Ensures last is non-empty.""" |
| 16090 | nick = (nick or "").strip() |
| 16091 | if not nick: |
| 16092 | return fallback_last, fallback_last |
| 16093 | parts = [p for p in re.split(r"\s+", nick) if p] |
| 16094 | if not parts: |
| 16095 | return fallback_last, fallback_last |
| 16096 | first = parts[0].strip() |
| 16097 | last = " ".join(parts[1:]).strip() |
| 16098 | if not last: |
| 16099 | last = fallback_last |
| 16100 | return first[:120], last[:120] |
| 16101 | |
| 16102 | def _clean_num(s: str) -> str: |
| 16103 | s = (s or "").strip() |
| 16104 | if not s: |
| 16105 | return "" |
| 16106 | # Keep digits and a dot/comma (best-effort). |
| 16107 | s2 = re.sub(r"[^0-9\.,]", "", s) |
| 16108 | return s2.strip() |
| 16109 | |
| 16110 | def profiler_sync_from_user_profile(username: str): |
| 16111 | """Ensure a user's My Profile is mirrored into their Profiler list. |
| 16112 | |
| 16113 | This creates (or updates) one special encrypted Profiler entry owned by the same user. |
| 16114 | No username is excluded from the profile -> profiler sync. |
| 16115 | """ |
| 16116 | if not username: |
| 16117 | return |
| 16118 | prof = get_profile(username) or {} |
nothing calls this directly
no test coverage detected