add_import: Add an Import Statement to Python Files in the _rixpress...

View source: R/parse_pkgs.R

add_importR Documentation

Add an Import Statement to Python Files in the _rixpress Folder Matching a Nix Environment Name

Description

This function appends a specified import statement to the end of each Python file within the ⁠_rixpress⁠ folder and its subdirectories, but only for files whose base name matches the provided Nix environment.

Usage

add_import(import_statement, nix_env, project_path = ".")

Arguments

import_statement

A character string representing the import statement to be added. For example, "import numpy as np".

nix_env

A character string naming the Nix environment file (e.g. "default.nix" or "py-env.nix" or similar).

project_path

Path to root of project, typically ".".

Value

No return value; the function performs in-place modifications of the files.

See Also

Other python import: adjust_import()

Examples

## Not run: 
add_import("import numpy as np", "default.nix")
add_import("import numpy as np", "default.nix", project_path = "path/to/project")

## End(Not run)

rixpress documentation built on Feb. 19, 2026, 9:06 a.m.