nyms.tools#
The SSOT of operations: plain functions, JSON-able in and out, surface-agnostic.
The CLI (nyms.__main__, via cw) dispatches this module’s _dispatch_funcs; an MCP
server (py2mcp.mk_mcp_from_refs(['nyms.tools:pseudonymise', ...])) or an HTTP adapter would
reference the same names. Nothing here prints or exits; nothing imports a surface.
Every verb takes the content as positional text or, exclusively, a path (a UTF-8 file,
or - for stdin). The two are never guessed from each other: a value that happens to be an
existing path is still text. The project key is touched only when a verb needs it.
Functions
|
Originals of project that occur in the text: what would leak if this text were sent. |
|
The spans the deterministic pass finds, with the policy's decision for each. |
|
The project's records (surrogate, original, type). |
|
The policy presets and the entity types each replaces. |
|
Replace detected identifiers in the text (or the file at path) with surrogates; the project's mapping remembers them. |
|
A keyed hash of value under the project's key, rendered as readable words. |
|
Put the originals back into the text (an AI's answer, say). |
- nyms.tools.check(text='', *, path='', project='default', encrypt=False)[source]#
Originals of project that occur in the text: what would leak if this text were sent.
- Return type:
- nyms.tools.detect(text='', *, path='', names='', policy='default')[source]#
The spans the deterministic pass finds, with the policy’s decision for each. Nothing is stored.
- nyms.tools.mapping(project='default', *, encrypt=False)[source]#
The project’s records (surrogate, original, type). Sensitive: this is the key to the text.
- nyms.tools.pseudonymise(text='', *, path='', project='default', out=None, policy='default', names='', strategy='counter', aliases='', encrypt=False)[source]#
Replace detected identifiers in the text (or the file at path) with surrogates; the project’s mapping remembers them.
names: comma-separated names you already know (the parties). aliases:
Name=Alias,...surrogates you choose yourself. strategy:counter([PERSON_1]),keyed-wordsorrandom-words. The result carries the text (or theoutpath) and the run report.- Return type: