5050)
5151
5252
53- class _ChRootContext (object ):
53+ # noinspection PyProtectedMember
54+ class _ChRootContext (object ): # pylint: disable=protected-access
5455 """Context manager for call commands with chroot.
5556
5657 .. versionadded:: 1.12.0
5758 """
5859
59- __slots__ = ("__conn " , "__chroot_status " , "__path " )
60+ __slots__ = ("_conn " , "_chroot_status " , "_path " )
6061
6162 def __init__ (
6263 self ,
6364 conn , # type: ExecHelper
6465 path = None , # type: typing.Optional[typing.Union[str, typing.Text]]
65- ): # type: (...) -> None
66+ ): # type: (...) -> None # pylint: disable=protected-access
6667 """Context manager for call commands with sudo.
6768
6869 :param conn: connection instance
6970 :type conn: ExecHelper
7071 :param path: chroot path or None for no chroot
7172 :type path: typing.Optional[str]
7273 """
73- self .__conn = conn # type: ExecHelper
74- self .__chroot_status = conn .chroot_path # type: typing.Optional[typing.Union[str, typing.Text]]
75- self .__path = path # type: typing.Optional[typing.Union[str, typing.Text]]
74+ self ._conn = conn # type: ExecHelper
75+ self ._chroot_status = conn ._chroot_path # type: typing.Optional[typing.Union[str, typing.Text]]
76+ self ._path = path # type: typing.Optional[typing.Union[str, typing.Text]]
7677
7778 def __enter__ (self ): # type: () -> None
78- self .__conn .__enter__ ()
79- self .__chroot_status = self .__conn . chroot_path
80- self .__conn . chroot_path = self .__path
79+ self ._conn .__enter__ ()
80+ self ._chroot_status = self ._conn . _chroot_path # pylint: disable=protected-access
81+ self ._conn . _chroot_path = self ._path # pylint: disable=protected-access
8182
8283 def __exit__ (self , exc_type , exc_val , exc_tb ): # type: (typing.Any, typing.Any, typing.Any) -> None
83- self .__conn . chroot_path = self .__chroot_status
84- self .__conn .__exit__ (exc_type = exc_type , exc_val = exc_val , exc_tb = exc_tb ) # type: ignore
84+ self ._conn . _chroot_path = self ._chroot_status # pylint: disable=protected-access
85+ self ._conn .__exit__ (exc_type = exc_type , exc_val = exc_val , exc_tb = exc_tb ) # type: ignore
8586
8687
8788class ExecHelper (six .with_metaclass (abc .ABCMeta , object )):
@@ -92,17 +93,14 @@ class ExecHelper(six.with_metaclass(abc.ABCMeta, object)):
9293 def __init__ (
9394 self ,
9495 logger , # type: logging.Logger
95- log_mask_re = None , # type: typing.Optional[typing.Text]
96- chroot_path = None # type: typing.Optional[typing.Union[str, typing.Text]]
96+ log_mask_re = None # type: typing.Optional[typing.Text]
9797 ): # type: (...) -> None
9898 """Global ExecHelper API.
9999
100100 :param logger: logger instance to use
101101 :type logger: logging.Logger
102102 :param log_mask_re: regex lookup rule to mask command for logger.
103103 all MATCHED groups will be replaced by '<*masked*>'
104- :param chroot_path: chroot path (use chroot if set)
105- :type chroot_path: typing.Optional[str]
106104 :type log_mask_re: typing.Optional[str]
107105
108106 .. versionchanged:: 1.2.0 log_mask_re regex rule for masking cmd
@@ -112,24 +110,24 @@ def __init__(
112110 self .__lock = threading .RLock ()
113111 self .__logger = logger
114112 self .log_mask_re = log_mask_re # type: typing.Optional[typing.Text]
115- self .__chroot_path = chroot_path # type: typing.Optional[typing.Union[str, typing.Text]]
113+ self .__chroot_path = None # type: typing.Optional[typing.Union[str, typing.Text]]
116114
117115 @property
118116 def logger (self ): # type: () -> logging.Logger
119117 """Instance logger access."""
120118 return self .__logger
121119
122120 @property
123- def chroot_path (self ): # type: () -> typing.Optional[typing.Union[str, typing.Text]]
121+ def _chroot_path (self ): # type: () -> typing.Optional[typing.Union[str, typing.Text]]
124122 """Path for chroot if set.
125123
126124 :rtype: typing.Optional[typing.Text]
127125 .. versionadded:: 1.12.0
128126 """
129127 return self .__chroot_path
130128
131- @chroot_path .setter
132- def chroot_path (self , new_state ): # type: (typing.Optional[typing.Union[str, typing.Text]]) -> None
129+ @_chroot_path .setter
130+ def _chroot_path (self , new_state ): # type: (typing.Optional[typing.Union[str, typing.Text]]) -> None
133131 """Path for chroot if set.
134132
135133 :param new_state: new path
@@ -138,8 +136,8 @@ def chroot_path(self, new_state): # type: (typing.Optional[typing.Union[str, ty
138136 """
139137 self .__chroot_path = new_state
140138
141- @chroot_path .deleter
142- def chroot_path (self ): # type: () -> None
139+ @_chroot_path .deleter
140+ def _chroot_path (self ): # type: () -> None
143141 """Remove Path for chroot.
144142
145143 .. versionadded:: 1.12.0
@@ -231,9 +229,9 @@ def _prepare_command(
231229 chroot_path = None # type: typing.Optional[typing.Union[str, typing.Text]]
232230 ): # type: (...) -> typing.Text
233231 """Prepare command: cower chroot and other cases."""
234- if any ((chroot_path , self .chroot_path )):
232+ if any ((chroot_path , self ._chroot_path )):
235233 return "chroot {chroot_path} {cmd}" .format (
236- chroot_path = chroot_path if chroot_path else self .chroot_path ,
234+ chroot_path = chroot_path if chroot_path else self ._chroot_path ,
237235 cmd = cmd
238236 )
239237 return cmd
0 commit comments