

'''simple docstring'''




import os
import sys
import time

from . import transposition_cipher as trans_cipher


def  lowerCamelCase__						(  ):
  UpperCAmelCase  							=		'Prehistoric Men.txt'
  UpperCAmelCase  							=		'Output.txt'
  UpperCAmelCase  							=		int(input('Enter key: '  )  )
  UpperCAmelCase  							=		input('Encrypt/Decrypt [e/d]: '  )

  if not os.path.exists(SCREAMING_SNAKE_CASE  ):
    print(f'''File {input_file} does not exist. Quitting...'''  )
    sys.exit()
  if os.path.exists(SCREAMING_SNAKE_CASE  ):
    print(f'''Overwrite {output_file}? [y/n]'''  )
    UpperCAmelCase  							=		input('> '  )
    if not response.lower().startswith('y'  ):
      sys.exit()

  UpperCAmelCase  							=		time.time()
  if mode.lower().startswith('e'  ):
    with open(SCREAMING_SNAKE_CASE  ) as f:
      UpperCAmelCase  							=		f.read()
    UpperCAmelCase  							=		trans_cipher.encrypt_message(SCREAMING_SNAKE_CASE    ,				SCREAMING_SNAKE_CASE  )
  elif mode.lower().startswith('d'  ):
    with open(SCREAMING_SNAKE_CASE  ) as f:
      UpperCAmelCase  							=		f.read()
    UpperCAmelCase  							=		trans_cipher.decrypt_message(SCREAMING_SNAKE_CASE    ,				SCREAMING_SNAKE_CASE  )

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

  UpperCAmelCase  							=		round(time.time() - start_time    ,				2  )
  print(('Done (', total_time, 'seconds )')  )


if __name__ == "__main__":
  main()





'''simple docstring'''




def  lowerCamelCase__						(  SCREAMING_SNAKE_CASE :				str  ):
  UpperCAmelCase  							=		str(SCREAMING_SNAKE_CASE  ).strip()
  if not bin_string:
    raise ValueError('Empty string was passed to the function'  )
  UpperCAmelCase  							=		bin_string[0] == '-'
  if is_negative:
    UpperCAmelCase  							=		bin_string[1:]
  if not all(char in '01' for char in bin_string  ):
    raise ValueError('Non-binary value was passed to the function'  )
  UpperCAmelCase  							=		0
  for char in bin_string:
    UpperCAmelCase  							=		2 * decimal_number + int(SCREAMING_SNAKE_CASE  )
  return -decimal_number if is_negative else decimal_number


if __name__ == "__main__":
  from doctest import testmod

  testmod()


