xonsh.lib.string

xonsh.lib.string.commonprefix(m: Iterable[str]) → str[source]

Given an iterable of strings, returns the longest common leading substring

xonsh.lib.string.endswith_newline(s: str) → str[source]

Return a string ending with exactly one newline character.

xonsh.lib.string.is_balanced(expr: str, ltok: str, rtok: str) → bool[source]

Determines whether an expression has unbalanced opening and closing tokens.

xonsh.lib.string.subexpr_before_unbalanced(expr: str, ltok: str, rtok: str) → str[source]

Obtains the expression prior to last unbalanced left token.

xonsh.lib.string.subexpr_from_unbalanced(expr: str, ltok: str, rtok: str) → str[source]

Attempts to pull out a valid subexpression for unbalanced grouping, based on opening tokens, eg. ‘(’, and closing tokens, eg. ‘)’. This does not do full tokenization, but should be good enough for tab completion.

xonsh.lib.string.unquote(s: str, chars: str = '\'"') → str[source]

Strip one pair of matching quote characters from a string.