unar_example.py 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # For accesing the module
  2. import sys, os
  3. sys.path.append(os.path.abspath('..'))
  4. from unar import Unar
  5. from unar import UnknownOption, ArchiveNotFound, StreamError, PasswordError
  6. """ Options
  7. test.output = ""
  8. test.forceOverwrite = False
  9. test.forceRename = False
  10. test.forceSkip = False
  11. test.forceDirectory = False
  12. test.noDirectory = False
  13. test.password = ""
  14. test.encoding = None # TODO
  15. test.passwordEncoding = None # TODO
  16. test.indexes = []
  17. test.noRecursion = False
  18. test.copyTime = False
  19. test.forks = False
  20. test.quiet = False
  21. """
  22. unar = Unar()
  23. unar.forceOverwrite = False
  24. unar.output = './extracted/'
  25. unar.file = 'example.zip'
  26. print(unar._compileCmd())
  27. try:
  28. unar.run()
  29. except UnknownOption as err:
  30. print("Version mismatch? Error: {0}".format(err))
  31. except ArchiveNotFound as err:
  32. print("ArchiveNotFound Error: {0}".format(err))
  33. except StreamError as err:
  34. print("StreamError Error: {0}".format(err))
  35. except PasswordError as err:
  36. print("PasswordError Error: {0}".format(err))