from __future__ import annotations

from typing import Generic, TypeVar

lowercase_  							=			TypeVar("T")







class      SCREAMING_SNAKE_CASE__					(  Generic[T]    ):

       def __init__(							self					:     str			,			_lowerCAmelCase					:     T			):
           __snake_case       :				str 			=    data  # Assign data
           __snake_case       :				Node[T] | None 			=    None  # Initialize next as null
           __snake_case       :				Node[T] | None 			=    None  # Initialize prev as null







class      SCREAMING_SNAKE_CASE__					(  Generic[T]    ):

       def __init__(							self					:     Dict			):
           __snake_case       :				Node[T] | None 			=    None

       def 			snake_case__    (							self					:     Union[str, Any]			,			_lowerCAmelCase					:     T			):



           if self.head is None:
               __snake_case       :				Tuple 			=    Node(lowerCAmelCase__			)
           else:
               __snake_case       :				str 			=    Node(lowerCAmelCase__			)
               __snake_case       :				List[str] 			=    new_node
               __snake_case       :				Union[str, Any] 			=    self.head
               __snake_case       :				str 			=    None
               __snake_case       :				Optional[Any] 			=    new_node

       def 			snake_case__    (							self					:     int			):



           if self.head is None:
               return None
           else:
               assert self.head is not None
               __snake_case       :				Optional[int] 			=    self.head.data
               __snake_case       :				Optional[int] 			=    self.head.next
               if self.head is not None:
                   __snake_case       :				List[Any] 			=    None
               return temp

       def 			snake_case__    (							self					:     Dict			):
           return self.head.data if self.head is not None else None

       def __len__(							self					:     Optional[int]			):
           __snake_case       :				Dict 			=    self.head
           __snake_case       :				Optional[Any] 			=    0
           while temp is not None:
               count += 1
               __snake_case       :				int 			=    temp.next
           return count

       def 			snake_case__    (							self					:     List[Any]			):
           return self.head is None





       def 			snake_case__    (							self					:     Union[str, Any]			):
           print("""stack elements are:"""			)
           __snake_case       :				Optional[int] 			=    self.head
           while temp is not None:
               print(temp.data			,			end="""->"""			)
               __snake_case       :				List[str] 			=    temp.next


# Code execution starts here
if __name__ == "__main__":
     # Start with the empty stack
     lowercase_  							=			Stack()

     # Insert 4 at the beginning. So stack becomes 4->None
     print("Stack operations using Doubly LinkedList")
     stack.push(4)

     # Insert 5 at the beginning. So stack becomes 4->5->None
     stack.push(5)

     # Insert 6 at the beginning. So stack becomes 4->5->6->None
     stack.push(6)

     # Insert 7 at the beginning. So stack becomes 4->5->6->7->None
     stack.push(7)

     # Print the stack
     stack.print_stack()

     # Print the top element
     print("\nTop element is ", stack.top())

     # Print the stack size
     print("Size of the stack is ", len(stack))

     # pop the top element
     stack.pop()

     # pop the top element
     stack.pop()

     # two elements have now been popped off
     stack.print_stack()

     # Print True if the stack is empty else False
     print("\nstack is empty:", stack.is_empty())










"""simple docstring"""




import os
import sys
import time

from . import transposition_cipher as trans_cipher





def 			a_							(				):
						_UpperCamelCase     :   Dict      =       '''Prehistoric Men.txt'''
						_UpperCamelCase     :   Optional[Any]      =       '''Output.txt'''
						_UpperCamelCase     :   Any      =       int(input('''Enter key: '''  )  )
						_UpperCamelCase     :   Optional[Any]      =       input('''Encrypt/Decrypt [e/d]: '''  )

						if not os.path.exists(_lowercase  ):
												print(F"""File {input_file} does not exist. Quitting..."""  )
												sys.exit()
						if os.path.exists(_lowercase  ):
												print(F"""Overwrite {output_file}? [y/n]"""  )
												_UpperCamelCase     :   Optional[int]      =       input('''> '''  )
												if not response.lower().startswith('''y'''  ):
																		sys.exit()

						_UpperCamelCase     :   List[str]      =       time.time()
						if mode.lower().startswith('''e'''  ):
												with open(_lowercase  ) as f:
																		_UpperCamelCase     :   Optional[int]      =       f.read()
												_UpperCamelCase     :   List[str]      =       trans_cipher.encrypt_message(_lowercase			,		_lowercase  )
						elif mode.lower().startswith('''d'''  ):
												with open(_lowercase  ) as f:
																		_UpperCamelCase     :   Dict      =       f.read()
												_UpperCamelCase     :   Any      =       trans_cipher.decrypt_message(_lowercase			,		_lowercase  )

						with open(_lowercase			,		'''w'''  ) as output_obj:
												output_obj.write(_lowercase  )

						_UpperCamelCase     :   List[str]      =       round(time.time() - start_time			,		2  )
						print(('''Done (''', total_time, '''seconds )''')  )


if __name__ == "__main__":
						main()



