You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.0 KiB

  1. # This module is used to map the old Python 2 names to the new names used in
  2. # Python 3 for the pickle module. This needed to make pickle streams
  3. # generated with Python 2 loadable by Python 3.
  4. # This is a copy of lib2to3.fixes.fix_imports.MAPPING. We cannot import
  5. # lib2to3 and use the mapping defined there, because lib2to3 uses pickle.
  6. # Thus, this could cause the module to be imported recursively.
  7. IMPORT_MAPPING = {
  8. 'StringIO': 'io',
  9. 'cStringIO': 'io',
  10. 'cPickle': 'pickle',
  11. '__builtin__' : 'builtins',
  12. 'copy_reg': 'copyreg',
  13. 'Queue': 'queue',
  14. 'SocketServer': 'socketserver',
  15. 'ConfigParser': 'configparser',
  16. 'repr': 'reprlib',
  17. 'FileDialog': 'tkinter.filedialog',
  18. 'tkFileDialog': 'tkinter.filedialog',
  19. 'SimpleDialog': 'tkinter.simpledialog',
  20. 'tkSimpleDialog': 'tkinter.simpledialog',
  21. 'tkColorChooser': 'tkinter.colorchooser',
  22. 'tkCommonDialog': 'tkinter.commondialog',
  23. 'Dialog': 'tkinter.dialog',
  24. 'Tkdnd': 'tkinter.dnd',
  25. 'tkFont': 'tkinter.font',
  26. 'tkMessageBox': 'tkinter.messagebox',
  27. 'ScrolledText': 'tkinter.scrolledtext',
  28. 'Tkconstants': 'tkinter.constants',
  29. 'Tix': 'tkinter.tix',
  30. 'ttk': 'tkinter.ttk',
  31. 'Tkinter': 'tkinter',
  32. 'markupbase': '_markupbase',
  33. '_winreg': 'winreg',
  34. 'thread': '_thread',
  35. 'dummy_thread': '_dummy_thread',
  36. 'dbhash': 'dbm.bsd',
  37. 'dumbdbm': 'dbm.dumb',
  38. 'dbm': 'dbm.ndbm',
  39. 'gdbm': 'dbm.gnu',
  40. 'xmlrpclib': 'xmlrpc.client',
  41. 'DocXMLRPCServer': 'xmlrpc.server',
  42. 'SimpleXMLRPCServer': 'xmlrpc.server',
  43. 'httplib': 'http.client',
  44. 'htmlentitydefs' : 'html.entities',
  45. 'HTMLParser' : 'html.parser',
  46. 'Cookie': 'http.cookies',
  47. 'cookielib': 'http.cookiejar',
  48. 'BaseHTTPServer': 'http.server',
  49. 'SimpleHTTPServer': 'http.server',
  50. 'CGIHTTPServer': 'http.server',
  51. 'test.test_support': 'test.support',
  52. 'commands': 'subprocess',
  53. 'UserString' : 'collections',
  54. 'UserList' : 'collections',
  55. 'urlparse' : 'urllib.parse',
  56. 'robotparser' : 'urllib.robotparser',
  57. 'whichdb': 'dbm',
  58. 'anydbm': 'dbm'
  59. }
  60. # This contains rename rules that are easy to handle. We ignore the more
  61. # complex stuff (e.g. mapping the names in the urllib and types modules).
  62. # These rules should be run before import names are fixed.
  63. NAME_MAPPING = {
  64. ('__builtin__', 'xrange'): ('builtins', 'range'),
  65. ('__builtin__', 'reduce'): ('functools', 'reduce'),
  66. ('__builtin__', 'intern'): ('sys', 'intern'),
  67. ('__builtin__', 'unichr'): ('builtins', 'chr'),
  68. ('__builtin__', 'basestring'): ('builtins', 'str'),
  69. ('__builtin__', 'long'): ('builtins', 'int'),
  70. ('itertools', 'izip'): ('builtins', 'zip'),
  71. ('itertools', 'imap'): ('builtins', 'map'),
  72. ('itertools', 'ifilter'): ('builtins', 'filter'),
  73. ('itertools', 'ifilterfalse'): ('itertools', 'filterfalse'),
  74. }
  75. # Same, but for 3.x to 2.x
  76. REVERSE_IMPORT_MAPPING = dict((v, k) for (k, v) in IMPORT_MAPPING.items())
  77. REVERSE_NAME_MAPPING = dict((v, k) for (k, v) in NAME_MAPPING.items())