String manipulation
pyvider.components.functions.string_manipulation
¶
TODO: Add module docstring.
Classes¶
Functions¶
camel_case
¶
Convert text to camelCase (or PascalCase if upper_first is true).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
Text to convert |
required |
*options
|
bool
|
Optional boolean for upper_first (default: False) |
()
|
Returns:
| Type | Description |
|---|---|
str | None
|
Converted text in camelCase (default) or PascalCase |
Examples:
camel_case("my_var") → "myVar" camel_case("my_var", True) → "MyVar"
Source code in pyvider/components/functions/string_manipulation.py
format_file_size
¶
Format bytes as human-readable size (e.g., "1.5 KB", "2.3 MB").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size_bytes
|
int | None
|
Size in bytes |
required |
*options
|
int
|
Optional integer for precision (default: 1) |
()
|
Returns:
| Type | Description |
|---|---|
str | None
|
Formatted size string |
Examples:
format_file_size(1024) → "1.0 KB" format_file_size(1024, 2) → "1.00 KB"
Source code in pyvider/components/functions/string_manipulation.py
format_str
¶
Format a string template with positional arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str | None
|
String template with {} placeholders |
required |
values
|
list[Any] | None
|
List of values to insert into template |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Formatted string |
Examples:
format("Hello, {}!", ["World"]) → "Hello, World!" format("{} + {} = {}", [1, 2, 3]) → "1 + 2 = 3"
Source code in pyvider/components/functions/string_manipulation.py
join
¶
Join a list of strings with a delimiter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delimiter
|
str | None
|
String to use as separator (default: "") |
required |
strings
|
list[Any] | None
|
List of values to join |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Joined string |
Examples:
join(", ", ["apple", "banana", "cherry"]) → "apple, banana, cherry" join("", ["a", "b", "c"]) → "abc"
Source code in pyvider/components/functions/string_manipulation.py
kebab_case
¶
Convert text to kebab-case using provide-foundation utilities.
Source code in pyvider/components/functions/string_manipulation.py
lower
¶
Convert a string to lowercase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_str
|
str | None
|
String to convert |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Lowercase string |
Examples:
lower("HELLO") → "hello" lower("Hello World") → "hello world"
Source code in pyvider/components/functions/string_manipulation.py
pluralize_word
¶
Pluralize a word based on count with optional custom plural form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
word
|
str | None
|
Word to pluralize |
required |
*options
|
int | str
|
Optional args: - First: count (int, default: 1) - Second: plural (str, default: None for auto-pluralization) |
()
|
Returns:
| Type | Description |
|---|---|
str | None
|
Singular or plural form based on count |
Examples:
pluralize_word("apple") → "apple" pluralize_word("apple", 1) → "apple" pluralize_word("apple", 2) → "apples" pluralize_word("person", 2, "people") → "people"
Source code in pyvider/components/functions/string_manipulation.py
replace
¶
Replace all occurrences of a substring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string
|
str | None
|
String to modify |
required |
search
|
str | None
|
Substring to find |
required |
replacement
|
str | None
|
String to replace with |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Modified string |
Examples:
replace("hello world", "world", "earth") → "hello earth" replace("foo bar foo", "foo", "baz") → "baz bar baz"
Source code in pyvider/components/functions/string_manipulation.py
snake_case
¶
Convert text to snake_case using provide-foundation utilities.
Source code in pyvider/components/functions/string_manipulation.py
split
¶
Split a string by a delimiter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delimiter
|
str | None
|
Delimiter to split on (default: "") |
required |
string
|
str | None
|
String to split |
required |
Returns:
| Type | Description |
|---|---|
list[str] | None
|
List of string parts |
Examples:
split(",", "a,b,c") → ["a", "b", "c"] split(" ", "hello world") → ["hello", "world"]
Source code in pyvider/components/functions/string_manipulation.py
truncate_text
¶
Truncate text to specified length with optional suffix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
Text to truncate |
required |
*options
|
int | str
|
Optional args: - First: max_length (int, default: 100) - Second: suffix (str, default: "...") |
()
|
Returns:
| Type | Description |
|---|---|
str | None
|
Truncated text with suffix if needed |
Examples:
truncate_text("Hello World") → "Hello World" truncate_text("Very long text...", 10) → "Very lo..." truncate_text("Very long text...", 10, ">>") → "Very long>>"
Source code in pyvider/components/functions/string_manipulation.py
upper
¶
Convert a string to uppercase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_str
|
str | None
|
String to convert |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Uppercase string |
Examples:
upper("hello") → "HELLO" upper("Hello World") → "HELLO WORLD"