Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

brainprep.interfaces.utils.anonfile

brainprep.interfaces.utils.anonfile(input_file, mapping)[source]

Anonymize a text file using sed.

The function constructs a list of sed substitution expressions based on the user-provided mapping and additional system-derived identifiers (hostname, IP address, username). The resulting command performs in-place anonymization of the input file.

Parameters:
input_fileFile

Path to the file to anonymize.

mappingdict[str, str]

Patterns to replace (keys) and their replacements (values).

Returns:
commandlist[str]

The sed command-line used for anonization.

output_fileFile

Path to the anonymized file.