





import logging
import os
import threading
import time


try:
     import warnings
except ImportError:
     __lowercase	: int       =None

try:
     import msvcrt
except ImportError:
     __lowercase	: List[Any]       =None

try:
     import fcntl
except ImportError:
     __lowercase	: Union[str, Any]       =None


# Backward compatibility
# ------------------------------------------------
try:
     TimeoutError
except NameError:
     __lowercase	: List[str]       =OSError


# Data
# ------------------------------------------------
__lowercase	: Optional[Any]       =[
    """Timeout""",
    """BaseFileLock""",
    """WindowsFileLock""",
    """UnixFileLock""",
    """SoftFileLock""",
    """FileLock""",
]

__lowercase	: List[Any]       ="""3.0.12"""


__lowercase	: int       =None




def      a__			(       ):






   '''simple docstring'''






   global _logger
   UpperCAmelCase_           =_logger or logging.getLogger(__name__	)
   return _logger

class   A							(						__lowercase    ):



      def __init__(						self:    Any		,	_lowerCAmelCase:    int							)    ->     Any:
         '''simple docstring'''

         UpperCAmelCase_           =lock_file
         return None






      def __str__(						self:    List[str]							)    ->     Any:
         '''simple docstring'''

         UpperCAmelCase_           =F'The file lock \'{self.lock_file}\' could not be acquired.'
         return temp

class   A							:



      def __init__(						self:    List[Any]		,	_lowerCAmelCase:    Tuple							)    ->     Optional[int]:
         '''simple docstring'''

         UpperCAmelCase_           =lock
         return None



      def __enter__(						self:    Tuple							)    ->     Optional[int]:
         '''simple docstring'''

         return self.lock






      def __exit__(						self:    Optional[Any]		,	_lowerCAmelCase:    Optional[int]		,	_lowerCAmelCase:    int		,	_lowerCAmelCase:    Optional[int]							)    ->     Any:
         '''simple docstring'''

         self.lock.release()
         return None

class   A							:



      def __init__(						self:    Optional[int]		,	_lowerCAmelCase:    Optional[int]		,	_lowerCAmelCase:    Tuple=-1		,	_lowerCAmelCase:    Optional[Any]=None							)    ->     List[Any]:
         '''simple docstring'''

         UpperCAmelCase_           =max_filename_length if max_filename_length is not None else 255
         # Hash the filename if it's too long
         UpperCAmelCase_           =self.hash_filename_if_too_long(_lowerCAmelCase		,	_lowerCAmelCase							)
         # The path to the lock file.
         UpperCAmelCase_           =lock_file

         # The file descriptor for the *_lock_file* as it is returned by the
         # os.open() function.
         # This file lock is only NOT None, if the object currently holds the
         # lock.
         UpperCAmelCase_           =None

         # The default timeout value.
         UpperCAmelCase_           =timeout

         # We use this lock primarily for the lock counter.
         UpperCAmelCase_           =threading.Lock()

         # The lock counter is used for implementing the nested locking
         # mechanism. Whenever the lock is acquired, the counter is increased and
         # the lock is only released, when this value is 0 again.
         UpperCAmelCase_           =0
         return None



      @property
      def 						lowerCAmelCase__     (						self:    Tuple							)    ->     Union[str, Any]:
         '''simple docstring'''

         return self._lock_file



      @property
      def 						lowerCAmelCase__     (						self:    Tuple							)    ->     int:
         '''simple docstring'''

         return self._timeout



      @timeout.setter
      def 						lowerCAmelCase__     (						self:    List[str]		,	_lowerCAmelCase:    Optional[Any]							)    ->     List[str]:
         '''simple docstring'''

         UpperCAmelCase_           =float(_lowerCAmelCase							)
         return None



      def 						lowerCAmelCase__     (						self:    Any							)    ->     Optional[Any]:
         '''simple docstring'''

         raise NotImplementedError()



      def 						lowerCAmelCase__     (						self:    List[Any]							)    ->     List[str]:
         '''simple docstring'''

         raise NotImplementedError()



      @property
      def 						lowerCAmelCase__     (						self:    Tuple							)    ->     Dict:
         '''simple docstring'''

         return self._lock_file_fd is not None



      def 						lowerCAmelCase__     (						self:    List[Any]		,	_lowerCAmelCase:    int=None		,	_lowerCAmelCase:    Dict=0.05							)    ->     Tuple:
         '''simple docstring'''

         if timeout is None:
            UpperCAmelCase_           =self.timeout

         # Increment the number right at the beginning.
         # We can still undo it, if something fails.
         with self._thread_lock:
            self._lock_counter += 1

         UpperCAmelCase_           =id(self							)
         UpperCAmelCase_           =self._lock_file
         UpperCAmelCase_           =time.time()
         try:
            while True:
               with self._thread_lock:
                  if not self.is_locked:
                     logger().debug(F'Attempting to acquire lock {lock_id} on {lock_filename}'							)
                     self._acquire()

               if self.is_locked:
                  logger().debug(F'Lock {lock_id} acquired on {lock_filename}'							)
                  break
               elif timeout >= 0 and time.time() - start_time > timeout:
                  logger().debug(F'Timeout on acquiring lock {lock_id} on {lock_filename}'							)
                  raise Timeout(self._lock_file							)
               else:
                  logger().debug(
                      F'Lock {lock_id} not acquired on {lock_filename}, waiting {poll_intervall} seconds ...'							)
                  time.sleep(_lowerCAmelCase							)
         except:  # noqa
            # Something did go wrong, so decrement the counter.
            with self._thread_lock:
               UpperCAmelCase_           =max(0		,	self._lock_counter - 1							)

            raise
         return _Acquire_ReturnProxy(lock=self							)



      def 						lowerCAmelCase__     (						self:    Any		,	_lowerCAmelCase:    Any=False							)    ->     Union[str, Any]:
         '''simple docstring'''

         with self._thread_lock:
            if self.is_locked:
               self._lock_counter -= 1

               if self._lock_counter == 0 or force:
                  UpperCAmelCase_           =id(self							)
                  UpperCAmelCase_           =self._lock_file

                  logger().debug(F'Attempting to release lock {lock_id} on {lock_filename}'							)
                  self._release()
                  UpperCAmelCase_           =0
                  logger().debug(F'Lock {lock_id} released on {lock_filename}'							)

         return None



      def __enter__(						self:    List[str]							)    ->     Optional[Any]:
         '''simple docstring'''

         self.acquire()
         return self



      def __exit__(						self:    Union[str, Any]		,	_lowerCAmelCase:    Optional[Any]		,	_lowerCAmelCase:    int		,	_lowerCAmelCase:    Dict							)    ->     Tuple:
         '''simple docstring'''

         self.release()
         return None



      def __del__(						self:    Dict							)    ->     Any:
         '''simple docstring'''

         self.release(force=_lowerCAmelCase							)
         return None






      def 						lowerCAmelCase__     (						self:    List[str]		,	_lowerCAmelCase:    str		,	_lowerCAmelCase:    int							)    ->     str:
         '''simple docstring'''

         UpperCAmelCase_           =os.path.basename(_lowerCAmelCase							)
         if len(_lowerCAmelCase							) > max_length and max_length > 0:
            UpperCAmelCase_           =os.path.dirname(_lowerCAmelCase							)
            UpperCAmelCase_           =str(hash(_lowerCAmelCase							)							)
            UpperCAmelCase_           =filename[: max_length - len(_lowerCAmelCase							) - 8] + "..." + hashed_filename + ".lock"
            return os.path.join(_lowerCAmelCase		,	_lowerCAmelCase							)
         else:
            return path

class   A							(						__lowercase    ):



      def __init__(						self:    Optional[Any]		,	_lowerCAmelCase:    Dict		,	_lowerCAmelCase:    List[str]=-1		,	_lowerCAmelCase:    Tuple=None							)    ->     Dict:
         '''simple docstring'''

         from .file_utils import relative_to_absolute_path

         super().__init__(_lowerCAmelCase		,	timeout=_lowerCAmelCase		,	max_filename_length=_lowerCAmelCase							)
         UpperCAmelCase_           ="\\\\?\\" + relative_to_absolute_path(self.lock_file							)



      def 						lowerCAmelCase__     (						self:    Union[str, Any]							)    ->     Optional[Any]:
         '''simple docstring'''

         UpperCAmelCase_           =os.O_RDWR | os.O_CREAT | os.O_TRUNC

         try:
            UpperCAmelCase_           =os.open(self._lock_file		,	_lowerCAmelCase							)
         except OSError:
            pass
         else:
            try:
               msvcrt.locking(_lowerCAmelCase		,	msvcrt.LK_NBLCK		,	1							)
            except OSError:
               os.close(_lowerCAmelCase							)
            else:
               UpperCAmelCase_           =fd
         return None






      def 						lowerCAmelCase__     (						self:    int							)    ->     List[str]:
         '''simple docstring'''

         UpperCAmelCase_           =self._lock_file_fd
         UpperCAmelCase_           =None
         msvcrt.locking(_lowerCAmelCase		,	msvcrt.LK_UNLCK		,	1							)
         os.close(_lowerCAmelCase							)

         try:
            os.remove(self._lock_file							)
         # Probably another instance of the application
         # that acquired the file lock.
         except OSError:
            pass
         return None

class   A							(						__lowercase    ):



      def __init__(						self:    List[Any]		,	_lowerCAmelCase:    Dict		,	_lowerCAmelCase:    str=-1		,	_lowerCAmelCase:    Dict=None							)    ->     str:
         '''simple docstring'''

         UpperCAmelCase_           =os.statvfs(os.path.dirname(_lowerCAmelCase							)							).f_namemax
         super().__init__(_lowerCAmelCase		,	timeout=_lowerCAmelCase		,	max_filename_length=_lowerCAmelCase							)



      def 						lowerCAmelCase__     (						self:    Optional[int]							)    ->     Dict:
         '''simple docstring'''

         UpperCAmelCase_           =os.O_RDWR | os.O_CREAT | os.O_TRUNC
         UpperCAmelCase_           =os.open(self._lock_file		,	_lowerCAmelCase							)

         try:
            fcntl.flock(_lowerCAmelCase		,	fcntl.LOCK_EX | fcntl.LOCK_NB							)
         except OSError:
            os.close(_lowerCAmelCase							)
         else:
            UpperCAmelCase_           =fd
         return None






      def 						lowerCAmelCase__     (						self:    Tuple							)    ->     Optional[Any]:
         '''simple docstring'''

         UpperCAmelCase_           =self._lock_file_fd
         UpperCAmelCase_           =None
         fcntl.flock(_lowerCAmelCase		,	fcntl.LOCK_UN							)
         os.close(_lowerCAmelCase							)
         return None

class   A							(						__lowercase    ):



      def 						lowerCAmelCase__     (						self:    Optional[int]							)    ->     List[Any]:
         '''simple docstring'''

         UpperCAmelCase_           =os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_TRUNC
         try:
            UpperCAmelCase_           =os.open(self._lock_file		,	_lowerCAmelCase							)
         except OSError:
            pass
         else:
            UpperCAmelCase_           =fd
         return None






      def 						lowerCAmelCase__     (						self:    Union[str, Any]							)    ->     int:
         '''simple docstring'''

         os.close(self._lock_file_fd							)
         UpperCAmelCase_           =None

         try:
            os.remove(self._lock_file							)
         # The file is already deleted and that's what we want.
         except OSError:
            pass
         return None

__lowercase	: int       =None

if msvcrt:
     __lowercase	: List[Any]       =WindowsFileLock
elif fcntl:
     __lowercase	: str       =UnixFileLock
else:
     __lowercase	: List[Any]       =SoftFileLock

     if warnings is not None:
          warnings.warn("""only soft file lock is available""")








def 							__lowerCamelCase		(					UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						int		):




      """simple docstring"""





      if b == 0:
            return 1
      if (b % 2) == 0:
            return actual_power(UpperCAmelCase_					,    int(b / 2		)		) * actual_power(UpperCAmelCase_					,    int(b / 2		)		)
      else:
            return a * actual_power(UpperCAmelCase_					,    int(b / 2		)		) * actual_power(UpperCAmelCase_					,    int(b / 2		)		)
def 							__lowerCamelCase		(					UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						int		):




      """simple docstring"""





      if b < 0:
            return 1 / actual_power(UpperCAmelCase_					,    UpperCAmelCase_		)
      return actual_power(UpperCAmelCase_					,    UpperCAmelCase_		)


if __name__ == "__main__":
     print(power(-2, -3))





