1212
1313
1414def string_bytes_bytearray_as_bytes (src : str | bytes | bytearray ) -> bytes :
15- """Get bytes string from string/bytes/bytearray union.
15+ """Get byte string from string/bytes/bytearray union.
1616
17- :param src: source string or bytes-like object
18- :return: Byte string
17+ :param src: Source string or bytes-like object.
18+ :return: Byte string.
1919 :rtype: bytes
2020 :raises TypeError: unexpected source type.
2121 """
@@ -31,11 +31,11 @@ def string_bytes_bytearray_as_bytes(src: str | bytes | bytearray) -> bytes:
3131def _mask_command (text : str , rules : str | re .Pattern [str ]) -> str :
3232 """Mask part of text using rules.
3333
34- :param text: source text
34+ :param text: Source text.
3535 :type text: str
36- :param rules: regex rules to mask.
36+ :param rules: Regex rules to mask.
3737 :type rules: str | re.Pattern
38- :return: source with all MATCHED groups replaced by '<*masked*>'
38+ :return: Source with all MATCHED groups replaced by '<*masked*>'.
3939 :rtype: str
4040 """
4141 masked : list [str ] = []
@@ -55,11 +55,11 @@ def _mask_command(text: str, rules: str | re.Pattern[str]) -> str:
5555def mask_command (text : str , * rules : str | re .Pattern [str ] | None ) -> str :
5656 """Apply all rules to command.
5757
58- :param text: source text
58+ :param text: Source text.
5959 :type text: str
60- :param rules: regex rules to mask.
60+ :param rules: Regex rules to mask.
6161 :type rules: str | re.Pattern[str] | None
62- :return: source with all MATCHED groups replaced by '<*masked*>'
62+ :return: Source with all MATCHED groups replaced by '<*masked*>'.
6363 :rtype: str
6464 """
6565 return functools .reduce (_mask_command , (rule for rule in rules if rule is not None ), text )
@@ -68,9 +68,9 @@ def mask_command(text: str, *rules: str | re.Pattern[str] | None) -> str:
6868def cmd_to_string (command : str | Iterable [str ]) -> str :
6969 """Convert command to string for usage with shell.
7070
71- :param command: original command.
71+ :param command: Original command.
7272 :type command: str | Iterable[str]
73- :return: command as single string
73+ :return: Command as single string.
7474 :rtype: str
7575 """
7676 if isinstance (command , str ):
@@ -81,13 +81,13 @@ def cmd_to_string(command: str | Iterable[str]) -> str:
8181def chroot_command (command : str , chroot_path : str | None = None , chroot_exe : str = "chroot" ) -> str :
8282 """Prepare command for chroot execution.
8383
84- :param command: original command.
84+ :param command: Original command.
8585 :type command: str
86- :param chroot_path: chroot path
86+ :param chroot_path: chroot path.
8787 :type chroot_path: str | None
88- :param chroot_exe: chroot executable
88+ :param chroot_exe: chroot executable.
8989 :type chroot_exe: str
90- :return: command to be executed with chroot rules if applicable
90+ :return: Command to be executed with chroot rules if applicable.
9191 :rtype: str
9292 """
9393 if chroot_path and chroot_path != "/" :
0 commit comments