
'''simple docstring'''

import logging
import os
import threading
import time


try:
    import warnings
except ImportError:
    __snake_case:	Tuple										=      None

try:
    import msvcrt
except ImportError:
    __snake_case:	Optional[Any]										=      None

try:
    import fcntl
except ImportError:
    __snake_case:	str										=      None


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


# Data
# ------------------------------------------------
__snake_case:	str										=      [
    "Timeout",
    "BaseFileLock",
    "WindowsFileLock",
    "UnixFileLock",
    "SoftFileLock",
    "FileLock",
]

__snake_case:	str										=      "3.0.12"


__snake_case:	Any										=      None






def 						_snake_case    (   ):
  """simple docstring"""







  global _logger
  a_   :						List[str]   =				_logger or logging.getLogger(__name__ )
  return _logger


class 			_UpperCAmelCase			(			__A     ):

     """simple docstring"""

     def __init__(   self				,		lowerCAmelCase_			):

       '''simple docstring'''

       a_   :						Dict   =				lock_file
       return None






     def __str__(   self			):

       '''simple docstring'''

       a_   :						str   =				f'''The file lock \'{self.lock_file}\' could not be acquired.'''
       return temp







class 			_UpperCAmelCase			:

     """simple docstring"""

     def __init__(   self				,		lowerCAmelCase_			):

       '''simple docstring'''

       a_   :						int   =				lock
       return None


     def __enter__(   self			):

       '''simple docstring'''

       return self.lock






     def __exit__(   self				,		lowerCAmelCase_				,		lowerCAmelCase_				,		lowerCAmelCase_			):

       '''simple docstring'''

       self.lock.release()
       return None







class 			_UpperCAmelCase			:

     """simple docstring"""

     def __init__(   self				,		lowerCAmelCase_				,		lowerCAmelCase_=-1				,		lowerCAmelCase_=None			):

       '''simple docstring'''

       a_   :						str   =				max_filename_length if max_filename_length is not None else 2_55
       # Hash the filename if it's too long
       a_   :						Dict   =				self.hash_filename_if_too_long(snake_case_				,		snake_case_			)
       # The path to the lock file.
       a_   :						Tuple   =				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.
       a_   :						Optional[int]   =				None

       # The default timeout value.
       a_   :						Optional[Any]   =				timeout

       # We use this lock primarily for the lock counter.
       a_   :						List[str]   =				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.
       a_   :						Any   =				0
       return None


     @property
     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       return self._lock_file


     @property
     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       return self._timeout


     @timeout.setter
     def 				_lowerCAmelCase	(   self				,		lowerCAmelCase_			):

       '''simple docstring'''

       a_   :						Optional[Any]   =				float(snake_case_			)
       return None


     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       raise NotImplementedError()


     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       raise NotImplementedError()


     @property
     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       return self._lock_file_fd is not None


     def 				_lowerCAmelCase	(   self				,		lowerCAmelCase_=None				,		lowerCAmelCase_=0.05			):

       '''simple docstring'''

       if timeout is None:
         a_   :						int   =				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

       a_   :						List[Any]   =				id(self			)
       a_   :						str   =				self._lock_file
       a_   :						Optional[Any]   =				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(snake_case_			)
       except:  # noqa
         # Something did go wrong, so decrement the counter.
         with self._thread_lock:
           a_   :						Optional[int]   =				max(0				,		self._lock_counter - 1			)

         raise
       return _Acquire_ReturnProxy(lock=self			)


     def 				_lowerCAmelCase	(   self				,		lowerCAmelCase_=False			):

       '''simple docstring'''

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

           if self._lock_counter == 0 or force:
             a_   :						List[str]   =				id(self			)
             a_   :						str   =				self._lock_file

             logger().debug(f'''Attempting to release lock {lock_id} on {lock_filename}'''			)
             self._release()
             a_   :						Union[str, Any]   =				0
             logger().debug(f'''Lock {lock_id} released on {lock_filename}'''			)

       return None


     def __enter__(   self			):

       '''simple docstring'''

       self.acquire()
       return self


     def __exit__(   self				,		lowerCAmelCase_				,		lowerCAmelCase_				,		lowerCAmelCase_			):

       '''simple docstring'''

       self.release()
       return None


     def __del__(   self			):

       '''simple docstring'''

       self.release(force=snake_case_			)
       return None






     def 				_lowerCAmelCase	(   self				,		lowerCAmelCase_				,		lowerCAmelCase_			):

       '''simple docstring'''

       a_   :						Union[str, Any]   =				os.path.basename(snake_case_			)
       if len(snake_case_			) > max_length and max_length > 0:
         a_   :						Optional[int]   =				os.path.dirname(snake_case_			)
         a_   :						Optional[int]   =				str(hash(snake_case_			)			)
         a_   :						Optional[Any]   =				filename[: max_length - len(snake_case_			) - 8] + """...""" + hashed_filename + """.lock"""
         return os.path.join(snake_case_				,		snake_case_			)
       else:
         return path







class 			_UpperCAmelCase			(			__A     ):

     """simple docstring"""

     def __init__(   self				,		lowerCAmelCase_				,		lowerCAmelCase_=-1				,		lowerCAmelCase_=None			):

       '''simple docstring'''

       from .file_utils import relative_to_absolute_path

       super().__init__(snake_case_				,		timeout=snake_case_				,		max_filename_length=snake_case_			)
       a_   :						Union[str, Any]   =				"""\\\\?\\""" + relative_to_absolute_path(self.lock_file			)


     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       a_   :						List[Any]   =				os.O_RDWR | os.O_CREAT | os.O_TRUNC

       try:
         a_   :						str   =				os.open(self._lock_file				,		snake_case_			)
       except OSError:
         pass
       else:
         try:
           msvcrt.locking(snake_case_				,		msvcrt.LK_NBLCK				,		1			)
         except OSError:
           os.close(snake_case_			)
         else:
           a_   :						Optional[int]   =				fd
       return None






     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       a_   :						Optional[int]   =				self._lock_file_fd
       a_   :						Tuple   =				None
       msvcrt.locking(snake_case_				,		msvcrt.LK_UNLCK				,		1			)
       os.close(snake_case_			)

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







class 			_UpperCAmelCase			(			__A     ):

     """simple docstring"""

     def __init__(   self				,		lowerCAmelCase_				,		lowerCAmelCase_=-1				,		lowerCAmelCase_=None			):

       '''simple docstring'''

       a_   :						Union[str, Any]   =				os.statvfs(os.path.dirname(snake_case_			)			).f_namemax
       super().__init__(snake_case_				,		timeout=snake_case_				,		max_filename_length=snake_case_			)


     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       a_   :						Any   =				os.O_RDWR | os.O_CREAT | os.O_TRUNC
       a_   :						Union[str, Any]   =				os.open(self._lock_file				,		snake_case_			)

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






     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       a_   :						Any   =				self._lock_file_fd
       a_   :						str   =				None
       fcntl.flock(snake_case_				,		fcntl.LOCK_UN			)
       os.close(snake_case_			)
       return None







class 			_UpperCAmelCase			(			__A     ):

     """simple docstring"""

     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       a_   :						Optional[int]   =				os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_TRUNC
       try:
         a_   :						Optional[Any]   =				os.open(self._lock_file				,		snake_case_			)
       except OSError:
         pass
       else:
         a_   :						Optional[Any]   =				fd
       return None






     def 				_lowerCAmelCase	(   self			):

       '''simple docstring'''

       os.close(self._lock_file_fd			)
       a_   :						List[Any]   =				None

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







__snake_case:	Tuple										=      None

if msvcrt:
    __snake_case:	List[Any]										=      WindowsFileLock
elif fcntl:
    __snake_case:	Optional[int]										=      UnixFileLock
else:
    __snake_case:	Dict										=      SoftFileLock

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



"""simple docstring"""



from collections.abc import Sequence

def  _A(		lowerCAmelCase			,  lowerCAmelCase							):
							return sum(c * (x**i) for i, c in enumerate(lowerCAmelCase							)							)

def  _A(		lowerCAmelCase			,  lowerCAmelCase							):
							A__       :     str								=			0.0
							for coeff in reversed(lowerCAmelCase							):
														A__       :     Optional[int]								=			result * x + coeff
							return result


if __name__ == "__main__":
				_UpperCamelCase								=		(0.0, 0.0, 5.0, 9.3, 7.0)
				_UpperCamelCase								=		10.0
				print(evaluate_poly(poly, x))
				print(horner(poly, x))





