utils
- gapic.utils.case.to_camel_case(s: str) → str[source]
Convert any string to camel case.
This is provided to templates as the
camel_case
filter.
- gapic.utils.case.to_snake_case(s: str) → str[source]
Convert any string to snake case.
This is provided to templates as the
snake_case
filter.
- gapic.utils.lines.sort_lines(text: str, dedupe: bool = True) → str[source]
Sort the individual lines of a block of text.
- Parameters
dedupe (bool) – Remove duplicate lines with the same text. Useful for dealing with import statements in templates.
- gapic.utils.lines.wrap(text: str, width: int, *, offset: Optional[int] = None, indent: int = 0) → str[source]
Wrap the given string to the given width.
This uses
textwrap.fill()
under the hood, but provides useful offset functionality for Jinja templates.This is provided to all templates as the
wrap
filter.- Parameters
text (str) – The initial text string.
width (int) – The width at which to wrap the text. If offset is provided, these are automatically counted against this.
offset (int) – The offset for the first line of text. This value is subtracted from
width
for the first line only, and is intended to represent the vertical position of the first line as already present in the template. Defaults to the value ofindent
.indent (int) – The number of spaces to indent all lines after the first one.
- Returns
The wrapped string.
- Return type