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.get_subsequent_line_indentation_level(list_item: str) int [source]
Given a list item return the indentation level for subsequent lines. For example, if it is a numbered list, the indentation level should be 3 as shown below.
Here subsequent lines should be indented by 2
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog
Here subsequent lines should be indented by 2
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog
Here subsequent lines should be indented by 4 to cater for double digits
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog
- gapic.utils.lines.is_list_item(list_item: str) bool [source]
Given a string return a boolean indicating whether a list is identified.
- 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