com.googler.python 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/package.json +4 -2
  2. package/python3.4.2/lib/python3.4/site-packages/pip/__init__.py +1 -277
  3. package/python3.4.2/lib/python3.4/site-packages/pip/__main__.py +19 -7
  4. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/__init__.py +246 -0
  5. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/basecommand.py +373 -0
  6. package/python3.4.2/lib/python3.4/site-packages/pip/{baseparser.py → _internal/baseparser.py} +240 -224
  7. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/build_env.py +92 -0
  8. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/cache.py +202 -0
  9. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/cmdoptions.py +609 -0
  10. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/__init__.py +79 -0
  11. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/check.py +42 -0
  12. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/completion.py +94 -0
  13. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/configuration.py +227 -0
  14. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/download.py +233 -0
  15. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/freeze.py +96 -0
  16. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/hash.py +57 -0
  17. package/python3.4.2/lib/python3.4/site-packages/pip/{commands → _internal/commands}/help.py +36 -33
  18. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/install.py +477 -0
  19. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/list.py +343 -0
  20. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/search.py +135 -0
  21. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/show.py +164 -0
  22. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/uninstall.py +71 -0
  23. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/wheel.py +179 -0
  24. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/compat.py +235 -0
  25. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/configuration.py +378 -0
  26. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/download.py +922 -0
  27. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/exceptions.py +249 -0
  28. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/index.py +1117 -0
  29. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/locations.py +194 -0
  30. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/models/__init__.py +4 -0
  31. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/models/index.py +15 -0
  32. package/python3.4.2/lib/python3.4/site-packages/pip/{_vendor/requests/packages/urllib3/contrib → _internal/operations}/__init__.py +0 -0
  33. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/operations/check.py +106 -0
  34. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/operations/freeze.py +252 -0
  35. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/operations/prepare.py +378 -0
  36. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/pep425tags.py +317 -0
  37. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/__init__.py +69 -0
  38. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/req_file.py +338 -0
  39. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/req_install.py +1115 -0
  40. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/req_set.py +164 -0
  41. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/req_uninstall.py +455 -0
  42. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/resolve.py +354 -0
  43. package/python3.4.2/lib/python3.4/site-packages/pip/{status_codes.py → _internal/status_codes.py} +8 -6
  44. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/__init__.py +0 -0
  45. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/appdirs.py +258 -0
  46. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/deprecation.py +77 -0
  47. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/encoding.py +33 -0
  48. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/filesystem.py +28 -0
  49. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/glibc.py +84 -0
  50. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/hashes.py +94 -0
  51. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/logging.py +132 -0
  52. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/misc.py +851 -0
  53. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/outdated.py +163 -0
  54. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/packaging.py +70 -0
  55. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/setuptools_build.py +8 -0
  56. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/temp_dir.py +82 -0
  57. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/typing.py +29 -0
  58. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/ui.py +421 -0
  59. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/__init__.py +471 -0
  60. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/bazaar.py +113 -0
  61. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/git.py +311 -0
  62. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/mercurial.py +105 -0
  63. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/subversion.py +271 -0
  64. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/wheel.py +817 -0
  65. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/__init__.py +109 -8
  66. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/appdirs.py +604 -0
  67. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/__init__.py +11 -0
  68. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/_cmd.py +60 -0
  69. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/adapter.py +134 -0
  70. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/cache.py +39 -0
  71. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +2 -0
  72. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +133 -0
  73. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +43 -0
  74. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/compat.py +29 -0
  75. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/controller.py +373 -0
  76. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/filewrapper.py +78 -0
  77. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/heuristics.py +138 -0
  78. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/serialize.py +194 -0
  79. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/wrapper.py +27 -0
  80. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/certifi/__init__.py +3 -0
  81. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/certifi/__main__.py +2 -0
  82. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests → certifi}/cacert.pem +1765 -2358
  83. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/certifi/core.py +37 -0
  84. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/__init__.py +39 -32
  85. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/big5freq.py +386 -0
  86. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/big5prober.py +47 -42
  87. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/chardistribution.py +233 -231
  88. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/charsetgroupprober.py +106 -0
  89. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/charsetprober.py +145 -0
  90. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/cli/__init__.py +1 -0
  91. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/cli/chardetect.py +85 -0
  92. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/codingstatemachine.py +88 -0
  93. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/compat.py +34 -34
  94. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/cp949prober.py +49 -44
  95. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/enums.py +76 -0
  96. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/escprober.py +101 -0
  97. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/escsm.py +246 -0
  98. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/eucjpprober.py +92 -0
  99. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/euckrfreq.py +195 -0
  100. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/euckrprober.py +47 -42
  101. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/euctwfreq.py +387 -428
  102. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/euctwprober.py +46 -41
  103. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/gb2312freq.py +283 -472
  104. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/gb2312prober.py +46 -41
  105. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/hebrewprober.py +292 -283
  106. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/jisfreq.py +325 -569
  107. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/jpcntx.py +233 -219
  108. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langbulgarianmodel.py +228 -229
  109. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langcyrillicmodel.py +333 -329
  110. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langgreekmodel.py +225 -225
  111. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langhebrewmodel.py +200 -201
  112. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langhungarianmodel.py +225 -225
  113. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langthaimodel.py +199 -200
  114. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/langturkishmodel.py +193 -0
  115. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/latin1prober.py +145 -139
  116. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/mbcharsetprober.py +91 -0
  117. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/mbcsgroupprober.py +54 -54
  118. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/mbcssm.py +572 -0
  119. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/sbcharsetprober.py +132 -0
  120. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/sbcsgroupprober.py +73 -69
  121. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/sjisprober.py +92 -0
  122. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/universaldetector.py +286 -0
  123. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/utf8prober.py +82 -76
  124. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/version.py +9 -0
  125. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/__init__.py +7 -7
  126. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/ansi.py +102 -50
  127. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/ansitowin32.py +236 -190
  128. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/initialise.py +82 -56
  129. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/win32.py +156 -137
  130. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/winterm.py +162 -120
  131. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/__init__.py +23 -23
  132. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/__init__.py +6 -6
  133. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/misc.py +41 -41
  134. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/shutil.py +761 -761
  135. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/sysconfig.cfg +84 -84
  136. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/sysconfig.py +788 -788
  137. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/tarfile.py +2607 -2607
  138. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/compat.py +1117 -1064
  139. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/database.py +1318 -1301
  140. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/index.py +516 -488
  141. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/locators.py +1292 -1194
  142. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/manifest.py +393 -364
  143. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/markers.py +131 -190
  144. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/metadata.py +1068 -1026
  145. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/resources.py +355 -317
  146. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py +415 -323
  147. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/t32.exe +0 -0
  148. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/t64.exe +0 -0
  149. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/util.py +1755 -1575
  150. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/version.py +736 -721
  151. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/w32.exe +0 -0
  152. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/w64.exe +0 -0
  153. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/wheel.py +984 -958
  154. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distro.py +1104 -0
  155. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/__init__.py +35 -23
  156. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{ihatexml.py → _ihatexml.py} +288 -285
  157. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{inputstream.py → _inputstream.py} +923 -881
  158. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{tokenizer.py → _tokenizer.py} +1721 -1731
  159. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{trie → _trie}/__init__.py +14 -12
  160. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{trie → _trie}/_base.py +37 -37
  161. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{trie → _trie}/datrie.py +44 -44
  162. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{trie → _trie}/py.py +67 -67
  163. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{utils.py → _utils.py} +124 -82
  164. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/constants.py +2947 -3104
  165. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.py +29 -20
  166. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/{_base.py → base.py} +12 -12
  167. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/inject_meta_charset.py +73 -65
  168. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/lint.py +93 -93
  169. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/optionaltags.py +207 -205
  170. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/sanitizer.py +896 -12
  171. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/whitespace.py +38 -38
  172. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/html5parser.py +2791 -2713
  173. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/serializer.py +409 -0
  174. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treeadapters/__init__.py +30 -0
  175. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treeadapters/genshi.py +54 -0
  176. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treeadapters/sax.py +50 -44
  177. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/__init__.py +88 -76
  178. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/{_base.py → base.py} +417 -377
  179. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/dom.py +236 -227
  180. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/etree.py +340 -337
  181. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.py +366 -369
  182. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/__init__.py +154 -57
  183. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/{_base.py → base.py} +252 -200
  184. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/dom.py +43 -46
  185. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/etree.py +130 -138
  186. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/{lxmletree.py → etree_lxml.py} +213 -208
  187. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/{genshistream.py → genshi.py} +69 -69
  188. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/__init__.py +2 -0
  189. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/codec.py +118 -0
  190. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/compat.py +12 -0
  191. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/core.py +387 -0
  192. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/idnadata.py +1585 -0
  193. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/intranges.py +53 -0
  194. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/package_data.py +2 -0
  195. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/uts46data.py +7634 -0
  196. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/ipaddress.py +2419 -0
  197. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/__init__.py +347 -0
  198. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/linklockfile.py +73 -0
  199. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/mkdirlockfile.py +84 -0
  200. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/pidlockfile.py +190 -0
  201. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/sqlitelockfile.py +156 -0
  202. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/symlinklockfile.py +70 -0
  203. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/msgpack/__init__.py +66 -0
  204. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/msgpack/_version.py +1 -0
  205. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/msgpack/exceptions.py +41 -0
  206. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/msgpack/fallback.py +971 -0
  207. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/__about__.py +21 -0
  208. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/__init__.py +14 -0
  209. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/_compat.py +30 -0
  210. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/_structures.py +70 -0
  211. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/markers.py +301 -0
  212. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/requirements.py +130 -0
  213. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/specifiers.py +774 -0
  214. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/utils.py +63 -0
  215. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/version.py +441 -0
  216. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{pkg_resources.py → pkg_resources/__init__.py} +3125 -2762
  217. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pkg_resources/py31compat.py +22 -0
  218. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/__init__.py +127 -0
  219. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/bar.py +88 -0
  220. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/counter.py +48 -0
  221. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/helpers.py +91 -0
  222. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/spinner.py +44 -0
  223. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pyparsing.py +5720 -0
  224. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pytoml/__init__.py +3 -0
  225. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pytoml/core.py +13 -0
  226. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pytoml/parser.py +374 -0
  227. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pytoml/writer.py +127 -0
  228. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/__init__.py +123 -77
  229. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/__version__.py +14 -0
  230. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/_internal_utils.py +42 -0
  231. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/adapters.py +525 -388
  232. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/api.py +152 -120
  233. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/auth.py +293 -193
  234. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/certs.py +18 -24
  235. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/compat.py +73 -115
  236. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/cookies.py +542 -454
  237. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/exceptions.py +122 -75
  238. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/help.py +120 -0
  239. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/hooks.py +34 -45
  240. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/models.py +948 -803
  241. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages.py +16 -0
  242. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/sessions.py +737 -637
  243. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/status_codes.py +91 -88
  244. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/structures.py +105 -127
  245. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/utils.py +904 -673
  246. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/retrying.py +267 -0
  247. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/six.py +891 -646
  248. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/__init__.py +97 -0
  249. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/_collections.py +319 -0
  250. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/connection.py +373 -0
  251. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/connectionpool.py +905 -710
  252. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
  253. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
  254. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +593 -0
  255. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +343 -0
  256. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/appengine.py +296 -0
  257. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/contrib/ntlmpool.py +112 -120
  258. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +455 -0
  259. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +810 -0
  260. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/socks.py +188 -0
  261. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/exceptions.py +246 -0
  262. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/fields.py +178 -177
  263. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/filepost.py +94 -100
  264. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/packages/__init__.py +5 -4
  265. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
  266. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +53 -0
  267. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/packages/ordered_dict.py +259 -260
  268. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/packages/six.py +868 -0
  269. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/packages/ssl_match_hostname/__init__.py +19 -13
  270. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/packages/ssl_match_hostname/_implementation.py +157 -105
  271. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/poolmanager.py +440 -0
  272. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/request.py +148 -141
  273. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/response.py +626 -0
  274. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/__init__.py +54 -0
  275. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/connection.py +130 -0
  276. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/request.py +118 -0
  277. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/response.py +81 -0
  278. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/retry.py +401 -0
  279. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/selectors.py +581 -0
  280. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/ssl_.py +341 -0
  281. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/util/timeout.py +242 -234
  282. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/util/url.py +230 -162
  283. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/wait.py +40 -0
  284. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/__init__.py +342 -0
  285. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/labels.py +231 -0
  286. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/mklabels.py +59 -0
  287. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/tests.py +153 -0
  288. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/x_user_defined.py +325 -0
  289. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/_markerlib/__init__.py +0 -16
  290. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/_markerlib/markers.py +0 -119
  291. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/sanitizer.py +0 -271
  292. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/serializer/__init__.py +0 -16
  293. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/serializer/htmlserializer.py +0 -320
  294. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/pulldom.py +0 -63
  295. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/re-vendor.py +0 -34
  296. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/__init__.py +0 -3
  297. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/big5freq.py +0 -925
  298. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py +0 -46
  299. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/charsetgroupprober.py +0 -106
  300. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/charsetprober.py +0 -62
  301. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/codingstatemachine.py +0 -61
  302. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/constants.py +0 -39
  303. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/escprober.py +0 -86
  304. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/escsm.py +0 -242
  305. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/eucjpprober.py +0 -90
  306. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/euckrfreq.py +0 -596
  307. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/mbcharsetprober.py +0 -86
  308. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/mbcssm.py +0 -575
  309. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/sbcharsetprober.py +0 -120
  310. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/sjisprober.py +0 -91
  311. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/universaldetector.py +0 -170
  312. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py +0 -58
  313. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/_collections.py +0 -205
  314. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connection.py +0 -204
  315. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py +0 -422
  316. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/exceptions.py +0 -126
  317. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/packages/six.py +0 -385
  318. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/poolmanager.py +0 -258
  319. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/response.py +0 -308
  320. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/__init__.py +0 -27
  321. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/connection.py +0 -45
  322. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/request.py +0 -68
  323. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/response.py +0 -13
  324. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py +0 -133
  325. package/python3.4.2/lib/python3.4/site-packages/pip/backwardcompat/__init__.py +0 -138
  326. package/python3.4.2/lib/python3.4/site-packages/pip/basecommand.py +0 -201
  327. package/python3.4.2/lib/python3.4/site-packages/pip/cmdoptions.py +0 -371
  328. package/python3.4.2/lib/python3.4/site-packages/pip/commands/__init__.py +0 -88
  329. package/python3.4.2/lib/python3.4/site-packages/pip/commands/bundle.py +0 -42
  330. package/python3.4.2/lib/python3.4/site-packages/pip/commands/completion.py +0 -59
  331. package/python3.4.2/lib/python3.4/site-packages/pip/commands/freeze.py +0 -114
  332. package/python3.4.2/lib/python3.4/site-packages/pip/commands/install.py +0 -314
  333. package/python3.4.2/lib/python3.4/site-packages/pip/commands/list.py +0 -162
  334. package/python3.4.2/lib/python3.4/site-packages/pip/commands/search.py +0 -132
  335. package/python3.4.2/lib/python3.4/site-packages/pip/commands/show.py +0 -80
  336. package/python3.4.2/lib/python3.4/site-packages/pip/commands/uninstall.py +0 -59
  337. package/python3.4.2/lib/python3.4/site-packages/pip/commands/unzip.py +0 -7
  338. package/python3.4.2/lib/python3.4/site-packages/pip/commands/wheel.py +0 -195
  339. package/python3.4.2/lib/python3.4/site-packages/pip/commands/zip.py +0 -351
  340. package/python3.4.2/lib/python3.4/site-packages/pip/download.py +0 -644
  341. package/python3.4.2/lib/python3.4/site-packages/pip/exceptions.py +0 -46
  342. package/python3.4.2/lib/python3.4/site-packages/pip/index.py +0 -990
  343. package/python3.4.2/lib/python3.4/site-packages/pip/locations.py +0 -171
  344. package/python3.4.2/lib/python3.4/site-packages/pip/log.py +0 -276
  345. package/python3.4.2/lib/python3.4/site-packages/pip/pep425tags.py +0 -102
  346. package/python3.4.2/lib/python3.4/site-packages/pip/req.py +0 -1931
  347. package/python3.4.2/lib/python3.4/site-packages/pip/runner.py +0 -18
  348. package/python3.4.2/lib/python3.4/site-packages/pip/util.py +0 -720
  349. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/__init__.py +0 -251
  350. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/bazaar.py +0 -131
  351. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/git.py +0 -194
  352. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/mercurial.py +0 -151
  353. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/subversion.py +0 -273
  354. package/python3.4.2/lib/python3.4/site-packages/pip/wheel.py +0 -560
@@ -0,0 +1,971 @@
1
+ """Fallback pure Python implementation of msgpack"""
2
+
3
+ import sys
4
+ import struct
5
+ import warnings
6
+
7
+ if sys.version_info[0] == 3:
8
+ PY3 = True
9
+ int_types = int
10
+ Unicode = str
11
+ xrange = range
12
+ def dict_iteritems(d):
13
+ return d.items()
14
+ else:
15
+ PY3 = False
16
+ int_types = (int, long)
17
+ Unicode = unicode
18
+ def dict_iteritems(d):
19
+ return d.iteritems()
20
+
21
+
22
+ if hasattr(sys, 'pypy_version_info'):
23
+ # cStringIO is slow on PyPy, StringIO is faster. However: PyPy's own
24
+ # StringBuilder is fastest.
25
+ from __pypy__ import newlist_hint
26
+ try:
27
+ from __pypy__.builders import BytesBuilder as StringBuilder
28
+ except ImportError:
29
+ from __pypy__.builders import StringBuilder
30
+ USING_STRINGBUILDER = True
31
+ class StringIO(object):
32
+ def __init__(self, s=b''):
33
+ if s:
34
+ self.builder = StringBuilder(len(s))
35
+ self.builder.append(s)
36
+ else:
37
+ self.builder = StringBuilder()
38
+ def write(self, s):
39
+ if isinstance(s, memoryview):
40
+ s = s.tobytes()
41
+ elif isinstance(s, bytearray):
42
+ s = bytes(s)
43
+ self.builder.append(s)
44
+ def getvalue(self):
45
+ return self.builder.build()
46
+ else:
47
+ USING_STRINGBUILDER = False
48
+ from io import BytesIO as StringIO
49
+ newlist_hint = lambda size: []
50
+
51
+
52
+ from pip._vendor.msgpack.exceptions import (
53
+ BufferFull,
54
+ OutOfData,
55
+ UnpackValueError,
56
+ PackValueError,
57
+ PackOverflowError,
58
+ ExtraData)
59
+
60
+ from pip._vendor.msgpack import ExtType
61
+
62
+
63
+ EX_SKIP = 0
64
+ EX_CONSTRUCT = 1
65
+ EX_READ_ARRAY_HEADER = 2
66
+ EX_READ_MAP_HEADER = 3
67
+
68
+ TYPE_IMMEDIATE = 0
69
+ TYPE_ARRAY = 1
70
+ TYPE_MAP = 2
71
+ TYPE_RAW = 3
72
+ TYPE_BIN = 4
73
+ TYPE_EXT = 5
74
+
75
+ DEFAULT_RECURSE_LIMIT = 511
76
+
77
+
78
+ def _check_type_strict(obj, t, type=type, tuple=tuple):
79
+ if type(t) is tuple:
80
+ return type(obj) in t
81
+ else:
82
+ return type(obj) is t
83
+
84
+
85
+ def _get_data_from_buffer(obj):
86
+ try:
87
+ view = memoryview(obj)
88
+ except TypeError:
89
+ # try to use legacy buffer protocol if 2.7, otherwise re-raise
90
+ if not PY3:
91
+ view = memoryview(buffer(obj))
92
+ warnings.warn("using old buffer interface to unpack %s; "
93
+ "this leads to unpacking errors if slicing is used and "
94
+ "will be removed in a future version" % type(obj),
95
+ RuntimeWarning)
96
+ else:
97
+ raise
98
+ if view.itemsize != 1:
99
+ raise ValueError("cannot unpack from multi-byte object")
100
+ return view
101
+
102
+
103
+ def unpack(stream, **kwargs):
104
+ warnings.warn(
105
+ "Direct calling implementation's unpack() is deprecated, Use msgpack.unpack() or unpackb() instead.",
106
+ PendingDeprecationWarning)
107
+ data = stream.read()
108
+ return unpackb(data, **kwargs)
109
+
110
+
111
+ def unpackb(packed, **kwargs):
112
+ """
113
+ Unpack an object from `packed`.
114
+
115
+ Raises `ExtraData` when `packed` contains extra bytes.
116
+ See :class:`Unpacker` for options.
117
+ """
118
+ unpacker = Unpacker(None, **kwargs)
119
+ unpacker.feed(packed)
120
+ try:
121
+ ret = unpacker._unpack()
122
+ except OutOfData:
123
+ raise UnpackValueError("Data is not enough.")
124
+ if unpacker._got_extradata():
125
+ raise ExtraData(ret, unpacker._get_extradata())
126
+ return ret
127
+
128
+
129
+ class Unpacker(object):
130
+ """Streaming unpacker.
131
+
132
+ arguments:
133
+
134
+ :param file_like:
135
+ File-like object having `.read(n)` method.
136
+ If specified, unpacker reads serialized data from it and :meth:`feed()` is not usable.
137
+
138
+ :param int read_size:
139
+ Used as `file_like.read(read_size)`. (default: `min(16*1024, max_buffer_size)`)
140
+
141
+ :param bool use_list:
142
+ If true, unpack msgpack array to Python list.
143
+ Otherwise, unpack to Python tuple. (default: True)
144
+
145
+ :param bool raw:
146
+ If true, unpack msgpack raw to Python bytes (default).
147
+ Otherwise, unpack to Python str (or unicode on Python 2) by decoding
148
+ with UTF-8 encoding (recommended).
149
+ Currently, the default is true, but it will be changed to false in
150
+ near future. So you must specify it explicitly for keeping backward
151
+ compatibility.
152
+
153
+ *encoding* option which is deprecated overrides this option.
154
+
155
+ :param callable object_hook:
156
+ When specified, it should be callable.
157
+ Unpacker calls it with a dict argument after unpacking msgpack map.
158
+ (See also simplejson)
159
+
160
+ :param callable object_pairs_hook:
161
+ When specified, it should be callable.
162
+ Unpacker calls it with a list of key-value pairs after unpacking msgpack map.
163
+ (See also simplejson)
164
+
165
+ :param str encoding:
166
+ Encoding used for decoding msgpack raw.
167
+ If it is None (default), msgpack raw is deserialized to Python bytes.
168
+
169
+ :param str unicode_errors:
170
+ (deprecated) Used for decoding msgpack raw with *encoding*.
171
+ (default: `'strict'`)
172
+
173
+ :param int max_buffer_size:
174
+ Limits size of data waiting unpacked. 0 means system's INT_MAX (default).
175
+ Raises `BufferFull` exception when it is insufficient.
176
+ You should set this parameter when unpacking data from untrusted source.
177
+
178
+ :param int max_str_len:
179
+ Limits max length of str. (default: 2**31-1)
180
+
181
+ :param int max_bin_len:
182
+ Limits max length of bin. (default: 2**31-1)
183
+
184
+ :param int max_array_len:
185
+ Limits max length of array. (default: 2**31-1)
186
+
187
+ :param int max_map_len:
188
+ Limits max length of map. (default: 2**31-1)
189
+
190
+
191
+ example of streaming deserialize from file-like object::
192
+
193
+ unpacker = Unpacker(file_like, raw=False)
194
+ for o in unpacker:
195
+ process(o)
196
+
197
+ example of streaming deserialize from socket::
198
+
199
+ unpacker = Unpacker(raw=False)
200
+ while True:
201
+ buf = sock.recv(1024**2)
202
+ if not buf:
203
+ break
204
+ unpacker.feed(buf)
205
+ for o in unpacker:
206
+ process(o)
207
+ """
208
+
209
+ def __init__(self, file_like=None, read_size=0, use_list=True, raw=True,
210
+ object_hook=None, object_pairs_hook=None, list_hook=None,
211
+ encoding=None, unicode_errors=None, max_buffer_size=0,
212
+ ext_hook=ExtType,
213
+ max_str_len=2147483647, # 2**32-1
214
+ max_bin_len=2147483647,
215
+ max_array_len=2147483647,
216
+ max_map_len=2147483647,
217
+ max_ext_len=2147483647):
218
+
219
+ if encoding is not None:
220
+ warnings.warn(
221
+ "encoding is deprecated, Use raw=False instead.",
222
+ PendingDeprecationWarning)
223
+
224
+ if unicode_errors is None:
225
+ unicode_errors = 'strict'
226
+
227
+ if file_like is None:
228
+ self._feeding = True
229
+ else:
230
+ if not callable(file_like.read):
231
+ raise TypeError("`file_like.read` must be callable")
232
+ self.file_like = file_like
233
+ self._feeding = False
234
+
235
+ #: array of bytes fed.
236
+ self._buffer = bytearray()
237
+ #: Which position we currently reads
238
+ self._buff_i = 0
239
+
240
+ # When Unpacker is used as an iterable, between the calls to next(),
241
+ # the buffer is not "consumed" completely, for efficiency sake.
242
+ # Instead, it is done sloppily. To make sure we raise BufferFull at
243
+ # the correct moments, we have to keep track of how sloppy we were.
244
+ # Furthermore, when the buffer is incomplete (that is: in the case
245
+ # we raise an OutOfData) we need to rollback the buffer to the correct
246
+ # state, which _buf_checkpoint records.
247
+ self._buf_checkpoint = 0
248
+
249
+ self._max_buffer_size = max_buffer_size or 2**31-1
250
+ if read_size > self._max_buffer_size:
251
+ raise ValueError("read_size must be smaller than max_buffer_size")
252
+ self._read_size = read_size or min(self._max_buffer_size, 16*1024)
253
+ self._raw = bool(raw)
254
+ self._encoding = encoding
255
+ self._unicode_errors = unicode_errors
256
+ self._use_list = use_list
257
+ self._list_hook = list_hook
258
+ self._object_hook = object_hook
259
+ self._object_pairs_hook = object_pairs_hook
260
+ self._ext_hook = ext_hook
261
+ self._max_str_len = max_str_len
262
+ self._max_bin_len = max_bin_len
263
+ self._max_array_len = max_array_len
264
+ self._max_map_len = max_map_len
265
+ self._max_ext_len = max_ext_len
266
+ self._stream_offset = 0
267
+
268
+ if list_hook is not None and not callable(list_hook):
269
+ raise TypeError('`list_hook` is not callable')
270
+ if object_hook is not None and not callable(object_hook):
271
+ raise TypeError('`object_hook` is not callable')
272
+ if object_pairs_hook is not None and not callable(object_pairs_hook):
273
+ raise TypeError('`object_pairs_hook` is not callable')
274
+ if object_hook is not None and object_pairs_hook is not None:
275
+ raise TypeError("object_pairs_hook and object_hook are mutually "
276
+ "exclusive")
277
+ if not callable(ext_hook):
278
+ raise TypeError("`ext_hook` is not callable")
279
+
280
+ def feed(self, next_bytes):
281
+ assert self._feeding
282
+ view = _get_data_from_buffer(next_bytes)
283
+ if (len(self._buffer) - self._buff_i + len(view) > self._max_buffer_size):
284
+ raise BufferFull
285
+
286
+ # Strip buffer before checkpoint before reading file.
287
+ if self._buf_checkpoint > 0:
288
+ del self._buffer[:self._buf_checkpoint]
289
+ self._buff_i -= self._buf_checkpoint
290
+ self._buf_checkpoint = 0
291
+
292
+ self._buffer += view
293
+
294
+ def _consume(self):
295
+ """ Gets rid of the used parts of the buffer. """
296
+ self._stream_offset += self._buff_i - self._buf_checkpoint
297
+ self._buf_checkpoint = self._buff_i
298
+
299
+ def _got_extradata(self):
300
+ return self._buff_i < len(self._buffer)
301
+
302
+ def _get_extradata(self):
303
+ return self._buffer[self._buff_i:]
304
+
305
+ def read_bytes(self, n):
306
+ return self._read(n)
307
+
308
+ def _read(self, n):
309
+ # (int) -> bytearray
310
+ self._reserve(n)
311
+ i = self._buff_i
312
+ self._buff_i = i+n
313
+ return self._buffer[i:i+n]
314
+
315
+ def _reserve(self, n):
316
+ remain_bytes = len(self._buffer) - self._buff_i - n
317
+
318
+ # Fast path: buffer has n bytes already
319
+ if remain_bytes >= 0:
320
+ return
321
+
322
+ if self._feeding:
323
+ self._buff_i = self._buf_checkpoint
324
+ raise OutOfData
325
+
326
+ # Strip buffer before checkpoint before reading file.
327
+ if self._buf_checkpoint > 0:
328
+ del self._buffer[:self._buf_checkpoint]
329
+ self._buff_i -= self._buf_checkpoint
330
+ self._buf_checkpoint = 0
331
+
332
+ # Read from file
333
+ remain_bytes = -remain_bytes
334
+ while remain_bytes > 0:
335
+ to_read_bytes = max(self._read_size, remain_bytes)
336
+ read_data = self.file_like.read(to_read_bytes)
337
+ if not read_data:
338
+ break
339
+ assert isinstance(read_data, bytes)
340
+ self._buffer += read_data
341
+ remain_bytes -= len(read_data)
342
+
343
+ if len(self._buffer) < n + self._buff_i:
344
+ self._buff_i = 0 # rollback
345
+ raise OutOfData
346
+
347
+ def _read_header(self, execute=EX_CONSTRUCT):
348
+ typ = TYPE_IMMEDIATE
349
+ n = 0
350
+ obj = None
351
+ self._reserve(1)
352
+ b = self._buffer[self._buff_i]
353
+ self._buff_i += 1
354
+ if b & 0b10000000 == 0:
355
+ obj = b
356
+ elif b & 0b11100000 == 0b11100000:
357
+ obj = -1 - (b ^ 0xff)
358
+ elif b & 0b11100000 == 0b10100000:
359
+ n = b & 0b00011111
360
+ typ = TYPE_RAW
361
+ if n > self._max_str_len:
362
+ raise UnpackValueError("%s exceeds max_str_len(%s)", n, self._max_str_len)
363
+ obj = self._read(n)
364
+ elif b & 0b11110000 == 0b10010000:
365
+ n = b & 0b00001111
366
+ typ = TYPE_ARRAY
367
+ if n > self._max_array_len:
368
+ raise UnpackValueError("%s exceeds max_array_len(%s)", n, self._max_array_len)
369
+ elif b & 0b11110000 == 0b10000000:
370
+ n = b & 0b00001111
371
+ typ = TYPE_MAP
372
+ if n > self._max_map_len:
373
+ raise UnpackValueError("%s exceeds max_map_len(%s)", n, self._max_map_len)
374
+ elif b == 0xc0:
375
+ obj = None
376
+ elif b == 0xc2:
377
+ obj = False
378
+ elif b == 0xc3:
379
+ obj = True
380
+ elif b == 0xc4:
381
+ typ = TYPE_BIN
382
+ self._reserve(1)
383
+ n = self._buffer[self._buff_i]
384
+ self._buff_i += 1
385
+ if n > self._max_bin_len:
386
+ raise UnpackValueError("%s exceeds max_bin_len(%s)" % (n, self._max_bin_len))
387
+ obj = self._read(n)
388
+ elif b == 0xc5:
389
+ typ = TYPE_BIN
390
+ self._reserve(2)
391
+ n = struct.unpack_from(">H", self._buffer, self._buff_i)[0]
392
+ self._buff_i += 2
393
+ if n > self._max_bin_len:
394
+ raise UnpackValueError("%s exceeds max_bin_len(%s)" % (n, self._max_bin_len))
395
+ obj = self._read(n)
396
+ elif b == 0xc6:
397
+ typ = TYPE_BIN
398
+ self._reserve(4)
399
+ n = struct.unpack_from(">I", self._buffer, self._buff_i)[0]
400
+ self._buff_i += 4
401
+ if n > self._max_bin_len:
402
+ raise UnpackValueError("%s exceeds max_bin_len(%s)" % (n, self._max_bin_len))
403
+ obj = self._read(n)
404
+ elif b == 0xc7: # ext 8
405
+ typ = TYPE_EXT
406
+ self._reserve(2)
407
+ L, n = struct.unpack_from('Bb', self._buffer, self._buff_i)
408
+ self._buff_i += 2
409
+ if L > self._max_ext_len:
410
+ raise UnpackValueError("%s exceeds max_ext_len(%s)" % (L, self._max_ext_len))
411
+ obj = self._read(L)
412
+ elif b == 0xc8: # ext 16
413
+ typ = TYPE_EXT
414
+ self._reserve(3)
415
+ L, n = struct.unpack_from('>Hb', self._buffer, self._buff_i)
416
+ self._buff_i += 3
417
+ if L > self._max_ext_len:
418
+ raise UnpackValueError("%s exceeds max_ext_len(%s)" % (L, self._max_ext_len))
419
+ obj = self._read(L)
420
+ elif b == 0xc9: # ext 32
421
+ typ = TYPE_EXT
422
+ self._reserve(5)
423
+ L, n = struct.unpack_from('>Ib', self._buffer, self._buff_i)
424
+ self._buff_i += 5
425
+ if L > self._max_ext_len:
426
+ raise UnpackValueError("%s exceeds max_ext_len(%s)" % (L, self._max_ext_len))
427
+ obj = self._read(L)
428
+ elif b == 0xca:
429
+ self._reserve(4)
430
+ obj = struct.unpack_from(">f", self._buffer, self._buff_i)[0]
431
+ self._buff_i += 4
432
+ elif b == 0xcb:
433
+ self._reserve(8)
434
+ obj = struct.unpack_from(">d", self._buffer, self._buff_i)[0]
435
+ self._buff_i += 8
436
+ elif b == 0xcc:
437
+ self._reserve(1)
438
+ obj = self._buffer[self._buff_i]
439
+ self._buff_i += 1
440
+ elif b == 0xcd:
441
+ self._reserve(2)
442
+ obj = struct.unpack_from(">H", self._buffer, self._buff_i)[0]
443
+ self._buff_i += 2
444
+ elif b == 0xce:
445
+ self._reserve(4)
446
+ obj = struct.unpack_from(">I", self._buffer, self._buff_i)[0]
447
+ self._buff_i += 4
448
+ elif b == 0xcf:
449
+ self._reserve(8)
450
+ obj = struct.unpack_from(">Q", self._buffer, self._buff_i)[0]
451
+ self._buff_i += 8
452
+ elif b == 0xd0:
453
+ self._reserve(1)
454
+ obj = struct.unpack_from("b", self._buffer, self._buff_i)[0]
455
+ self._buff_i += 1
456
+ elif b == 0xd1:
457
+ self._reserve(2)
458
+ obj = struct.unpack_from(">h", self._buffer, self._buff_i)[0]
459
+ self._buff_i += 2
460
+ elif b == 0xd2:
461
+ self._reserve(4)
462
+ obj = struct.unpack_from(">i", self._buffer, self._buff_i)[0]
463
+ self._buff_i += 4
464
+ elif b == 0xd3:
465
+ self._reserve(8)
466
+ obj = struct.unpack_from(">q", self._buffer, self._buff_i)[0]
467
+ self._buff_i += 8
468
+ elif b == 0xd4: # fixext 1
469
+ typ = TYPE_EXT
470
+ if self._max_ext_len < 1:
471
+ raise UnpackValueError("%s exceeds max_ext_len(%s)" % (1, self._max_ext_len))
472
+ self._reserve(2)
473
+ n, obj = struct.unpack_from("b1s", self._buffer, self._buff_i)
474
+ self._buff_i += 2
475
+ elif b == 0xd5: # fixext 2
476
+ typ = TYPE_EXT
477
+ if self._max_ext_len < 2:
478
+ raise UnpackValueError("%s exceeds max_ext_len(%s)" % (2, self._max_ext_len))
479
+ self._reserve(3)
480
+ n, obj = struct.unpack_from("b2s", self._buffer, self._buff_i)
481
+ self._buff_i += 3
482
+ elif b == 0xd6: # fixext 4
483
+ typ = TYPE_EXT
484
+ if self._max_ext_len < 4:
485
+ raise UnpackValueError("%s exceeds max_ext_len(%s)" % (4, self._max_ext_len))
486
+ self._reserve(5)
487
+ n, obj = struct.unpack_from("b4s", self._buffer, self._buff_i)
488
+ self._buff_i += 5
489
+ elif b == 0xd7: # fixext 8
490
+ typ = TYPE_EXT
491
+ if self._max_ext_len < 8:
492
+ raise UnpackValueError("%s exceeds max_ext_len(%s)" % (8, self._max_ext_len))
493
+ self._reserve(9)
494
+ n, obj = struct.unpack_from("b8s", self._buffer, self._buff_i)
495
+ self._buff_i += 9
496
+ elif b == 0xd8: # fixext 16
497
+ typ = TYPE_EXT
498
+ if self._max_ext_len < 16:
499
+ raise UnpackValueError("%s exceeds max_ext_len(%s)" % (16, self._max_ext_len))
500
+ self._reserve(17)
501
+ n, obj = struct.unpack_from("b16s", self._buffer, self._buff_i)
502
+ self._buff_i += 17
503
+ elif b == 0xd9:
504
+ typ = TYPE_RAW
505
+ self._reserve(1)
506
+ n = self._buffer[self._buff_i]
507
+ self._buff_i += 1
508
+ if n > self._max_str_len:
509
+ raise UnpackValueError("%s exceeds max_str_len(%s)", n, self._max_str_len)
510
+ obj = self._read(n)
511
+ elif b == 0xda:
512
+ typ = TYPE_RAW
513
+ self._reserve(2)
514
+ n, = struct.unpack_from(">H", self._buffer, self._buff_i)
515
+ self._buff_i += 2
516
+ if n > self._max_str_len:
517
+ raise UnpackValueError("%s exceeds max_str_len(%s)", n, self._max_str_len)
518
+ obj = self._read(n)
519
+ elif b == 0xdb:
520
+ typ = TYPE_RAW
521
+ self._reserve(4)
522
+ n, = struct.unpack_from(">I", self._buffer, self._buff_i)
523
+ self._buff_i += 4
524
+ if n > self._max_str_len:
525
+ raise UnpackValueError("%s exceeds max_str_len(%s)", n, self._max_str_len)
526
+ obj = self._read(n)
527
+ elif b == 0xdc:
528
+ typ = TYPE_ARRAY
529
+ self._reserve(2)
530
+ n, = struct.unpack_from(">H", self._buffer, self._buff_i)
531
+ self._buff_i += 2
532
+ if n > self._max_array_len:
533
+ raise UnpackValueError("%s exceeds max_array_len(%s)", n, self._max_array_len)
534
+ elif b == 0xdd:
535
+ typ = TYPE_ARRAY
536
+ self._reserve(4)
537
+ n, = struct.unpack_from(">I", self._buffer, self._buff_i)
538
+ self._buff_i += 4
539
+ if n > self._max_array_len:
540
+ raise UnpackValueError("%s exceeds max_array_len(%s)", n, self._max_array_len)
541
+ elif b == 0xde:
542
+ self._reserve(2)
543
+ n, = struct.unpack_from(">H", self._buffer, self._buff_i)
544
+ self._buff_i += 2
545
+ if n > self._max_map_len:
546
+ raise UnpackValueError("%s exceeds max_map_len(%s)", n, self._max_map_len)
547
+ typ = TYPE_MAP
548
+ elif b == 0xdf:
549
+ self._reserve(4)
550
+ n, = struct.unpack_from(">I", self._buffer, self._buff_i)
551
+ self._buff_i += 4
552
+ if n > self._max_map_len:
553
+ raise UnpackValueError("%s exceeds max_map_len(%s)", n, self._max_map_len)
554
+ typ = TYPE_MAP
555
+ else:
556
+ raise UnpackValueError("Unknown header: 0x%x" % b)
557
+ return typ, n, obj
558
+
559
+ def _unpack(self, execute=EX_CONSTRUCT):
560
+ typ, n, obj = self._read_header(execute)
561
+
562
+ if execute == EX_READ_ARRAY_HEADER:
563
+ if typ != TYPE_ARRAY:
564
+ raise UnpackValueError("Expected array")
565
+ return n
566
+ if execute == EX_READ_MAP_HEADER:
567
+ if typ != TYPE_MAP:
568
+ raise UnpackValueError("Expected map")
569
+ return n
570
+ # TODO should we eliminate the recursion?
571
+ if typ == TYPE_ARRAY:
572
+ if execute == EX_SKIP:
573
+ for i in xrange(n):
574
+ # TODO check whether we need to call `list_hook`
575
+ self._unpack(EX_SKIP)
576
+ return
577
+ ret = newlist_hint(n)
578
+ for i in xrange(n):
579
+ ret.append(self._unpack(EX_CONSTRUCT))
580
+ if self._list_hook is not None:
581
+ ret = self._list_hook(ret)
582
+ # TODO is the interaction between `list_hook` and `use_list` ok?
583
+ return ret if self._use_list else tuple(ret)
584
+ if typ == TYPE_MAP:
585
+ if execute == EX_SKIP:
586
+ for i in xrange(n):
587
+ # TODO check whether we need to call hooks
588
+ self._unpack(EX_SKIP)
589
+ self._unpack(EX_SKIP)
590
+ return
591
+ if self._object_pairs_hook is not None:
592
+ ret = self._object_pairs_hook(
593
+ (self._unpack(EX_CONSTRUCT),
594
+ self._unpack(EX_CONSTRUCT))
595
+ for _ in xrange(n))
596
+ else:
597
+ ret = {}
598
+ for _ in xrange(n):
599
+ key = self._unpack(EX_CONSTRUCT)
600
+ ret[key] = self._unpack(EX_CONSTRUCT)
601
+ if self._object_hook is not None:
602
+ ret = self._object_hook(ret)
603
+ return ret
604
+ if execute == EX_SKIP:
605
+ return
606
+ if typ == TYPE_RAW:
607
+ if self._encoding is not None:
608
+ obj = obj.decode(self._encoding, self._unicode_errors)
609
+ elif self._raw:
610
+ obj = bytes(obj)
611
+ else:
612
+ obj = obj.decode('utf_8')
613
+ return obj
614
+ if typ == TYPE_EXT:
615
+ return self._ext_hook(n, bytes(obj))
616
+ if typ == TYPE_BIN:
617
+ return bytes(obj)
618
+ assert typ == TYPE_IMMEDIATE
619
+ return obj
620
+
621
+ def __iter__(self):
622
+ return self
623
+
624
+ def __next__(self):
625
+ try:
626
+ ret = self._unpack(EX_CONSTRUCT)
627
+ self._consume()
628
+ return ret
629
+ except OutOfData:
630
+ self._consume()
631
+ raise StopIteration
632
+
633
+ next = __next__
634
+
635
+ def skip(self, write_bytes=None):
636
+ self._unpack(EX_SKIP)
637
+ if write_bytes is not None:
638
+ warnings.warn("`write_bytes` option is deprecated. Use `.tell()` instead.", DeprecationWarning)
639
+ write_bytes(self._buffer[self._buf_checkpoint:self._buff_i])
640
+ self._consume()
641
+
642
+ def unpack(self, write_bytes=None):
643
+ ret = self._unpack(EX_CONSTRUCT)
644
+ if write_bytes is not None:
645
+ warnings.warn("`write_bytes` option is deprecated. Use `.tell()` instead.", DeprecationWarning)
646
+ write_bytes(self._buffer[self._buf_checkpoint:self._buff_i])
647
+ self._consume()
648
+ return ret
649
+
650
+ def read_array_header(self, write_bytes=None):
651
+ ret = self._unpack(EX_READ_ARRAY_HEADER)
652
+ if write_bytes is not None:
653
+ warnings.warn("`write_bytes` option is deprecated. Use `.tell()` instead.", DeprecationWarning)
654
+ write_bytes(self._buffer[self._buf_checkpoint:self._buff_i])
655
+ self._consume()
656
+ return ret
657
+
658
+ def read_map_header(self, write_bytes=None):
659
+ ret = self._unpack(EX_READ_MAP_HEADER)
660
+ if write_bytes is not None:
661
+ warnings.warn("`write_bytes` option is deprecated. Use `.tell()` instead.", DeprecationWarning)
662
+ write_bytes(self._buffer[self._buf_checkpoint:self._buff_i])
663
+ self._consume()
664
+ return ret
665
+
666
+ def tell(self):
667
+ return self._stream_offset
668
+
669
+
670
+ class Packer(object):
671
+ """
672
+ MessagePack Packer
673
+
674
+ usage:
675
+
676
+ packer = Packer()
677
+ astream.write(packer.pack(a))
678
+ astream.write(packer.pack(b))
679
+
680
+ Packer's constructor has some keyword arguments:
681
+
682
+ :param callable default:
683
+ Convert user type to builtin type that Packer supports.
684
+ See also simplejson's document.
685
+
686
+ :param bool use_single_float:
687
+ Use single precision float type for float. (default: False)
688
+
689
+ :param bool autoreset:
690
+ Reset buffer after each pack and return its content as `bytes`. (default: True).
691
+ If set this to false, use `bytes()` to get content and `.reset()` to clear buffer.
692
+
693
+ :param bool use_bin_type:
694
+ Use bin type introduced in msgpack spec 2.0 for bytes.
695
+ It also enables str8 type for unicode.
696
+
697
+ :param bool strict_types:
698
+ If set to true, types will be checked to be exact. Derived classes
699
+ from serializeable types will not be serialized and will be
700
+ treated as unsupported type and forwarded to default.
701
+ Additionally tuples will not be serialized as lists.
702
+ This is useful when trying to implement accurate serialization
703
+ for python types.
704
+
705
+ :param str encoding:
706
+ (deprecated) Convert unicode to bytes with this encoding. (default: 'utf-8')
707
+
708
+ :param str unicode_errors:
709
+ Error handler for encoding unicode. (default: 'strict')
710
+ """
711
+ def __init__(self, default=None, encoding=None, unicode_errors=None,
712
+ use_single_float=False, autoreset=True, use_bin_type=False,
713
+ strict_types=False):
714
+ if encoding is None:
715
+ encoding = 'utf_8'
716
+ else:
717
+ warnings.warn(
718
+ "encoding is deprecated, Use raw=False instead.",
719
+ PendingDeprecationWarning)
720
+
721
+ if unicode_errors is None:
722
+ unicode_errors = 'strict'
723
+
724
+ self._strict_types = strict_types
725
+ self._use_float = use_single_float
726
+ self._autoreset = autoreset
727
+ self._use_bin_type = use_bin_type
728
+ self._encoding = encoding
729
+ self._unicode_errors = unicode_errors
730
+ self._buffer = StringIO()
731
+ if default is not None:
732
+ if not callable(default):
733
+ raise TypeError("default must be callable")
734
+ self._default = default
735
+
736
+ def _pack(self, obj, nest_limit=DEFAULT_RECURSE_LIMIT,
737
+ check=isinstance, check_type_strict=_check_type_strict):
738
+ default_used = False
739
+ if self._strict_types:
740
+ check = check_type_strict
741
+ list_types = list
742
+ else:
743
+ list_types = (list, tuple)
744
+ while True:
745
+ if nest_limit < 0:
746
+ raise PackValueError("recursion limit exceeded")
747
+ if obj is None:
748
+ return self._buffer.write(b"\xc0")
749
+ if check(obj, bool):
750
+ if obj:
751
+ return self._buffer.write(b"\xc3")
752
+ return self._buffer.write(b"\xc2")
753
+ if check(obj, int_types):
754
+ if 0 <= obj < 0x80:
755
+ return self._buffer.write(struct.pack("B", obj))
756
+ if -0x20 <= obj < 0:
757
+ return self._buffer.write(struct.pack("b", obj))
758
+ if 0x80 <= obj <= 0xff:
759
+ return self._buffer.write(struct.pack("BB", 0xcc, obj))
760
+ if -0x80 <= obj < 0:
761
+ return self._buffer.write(struct.pack(">Bb", 0xd0, obj))
762
+ if 0xff < obj <= 0xffff:
763
+ return self._buffer.write(struct.pack(">BH", 0xcd, obj))
764
+ if -0x8000 <= obj < -0x80:
765
+ return self._buffer.write(struct.pack(">Bh", 0xd1, obj))
766
+ if 0xffff < obj <= 0xffffffff:
767
+ return self._buffer.write(struct.pack(">BI", 0xce, obj))
768
+ if -0x80000000 <= obj < -0x8000:
769
+ return self._buffer.write(struct.pack(">Bi", 0xd2, obj))
770
+ if 0xffffffff < obj <= 0xffffffffffffffff:
771
+ return self._buffer.write(struct.pack(">BQ", 0xcf, obj))
772
+ if -0x8000000000000000 <= obj < -0x80000000:
773
+ return self._buffer.write(struct.pack(">Bq", 0xd3, obj))
774
+ if not default_used and self._default is not None:
775
+ obj = self._default(obj)
776
+ default_used = True
777
+ continue
778
+ raise PackOverflowError("Integer value out of range")
779
+ if check(obj, (bytes, bytearray)):
780
+ n = len(obj)
781
+ if n >= 2**32:
782
+ raise PackValueError("%s is too large" % type(obj).__name__)
783
+ self._pack_bin_header(n)
784
+ return self._buffer.write(obj)
785
+ if check(obj, Unicode):
786
+ if self._encoding is None:
787
+ raise TypeError(
788
+ "Can't encode unicode string: "
789
+ "no encoding is specified")
790
+ obj = obj.encode(self._encoding, self._unicode_errors)
791
+ n = len(obj)
792
+ if n >= 2**32:
793
+ raise PackValueError("String is too large")
794
+ self._pack_raw_header(n)
795
+ return self._buffer.write(obj)
796
+ if check(obj, memoryview):
797
+ n = len(obj) * obj.itemsize
798
+ if n >= 2**32:
799
+ raise PackValueError("Memoryview is too large")
800
+ self._pack_bin_header(n)
801
+ return self._buffer.write(obj)
802
+ if check(obj, float):
803
+ if self._use_float:
804
+ return self._buffer.write(struct.pack(">Bf", 0xca, obj))
805
+ return self._buffer.write(struct.pack(">Bd", 0xcb, obj))
806
+ if check(obj, ExtType):
807
+ code = obj.code
808
+ data = obj.data
809
+ assert isinstance(code, int)
810
+ assert isinstance(data, bytes)
811
+ L = len(data)
812
+ if L == 1:
813
+ self._buffer.write(b'\xd4')
814
+ elif L == 2:
815
+ self._buffer.write(b'\xd5')
816
+ elif L == 4:
817
+ self._buffer.write(b'\xd6')
818
+ elif L == 8:
819
+ self._buffer.write(b'\xd7')
820
+ elif L == 16:
821
+ self._buffer.write(b'\xd8')
822
+ elif L <= 0xff:
823
+ self._buffer.write(struct.pack(">BB", 0xc7, L))
824
+ elif L <= 0xffff:
825
+ self._buffer.write(struct.pack(">BH", 0xc8, L))
826
+ else:
827
+ self._buffer.write(struct.pack(">BI", 0xc9, L))
828
+ self._buffer.write(struct.pack("b", code))
829
+ self._buffer.write(data)
830
+ return
831
+ if check(obj, list_types):
832
+ n = len(obj)
833
+ self._pack_array_header(n)
834
+ for i in xrange(n):
835
+ self._pack(obj[i], nest_limit - 1)
836
+ return
837
+ if check(obj, dict):
838
+ return self._pack_map_pairs(len(obj), dict_iteritems(obj),
839
+ nest_limit - 1)
840
+ if not default_used and self._default is not None:
841
+ obj = self._default(obj)
842
+ default_used = 1
843
+ continue
844
+ raise TypeError("Cannot serialize %r" % (obj, ))
845
+
846
+ def pack(self, obj):
847
+ try:
848
+ self._pack(obj)
849
+ except:
850
+ self._buffer = StringIO() # force reset
851
+ raise
852
+ ret = self._buffer.getvalue()
853
+ if self._autoreset:
854
+ self._buffer = StringIO()
855
+ elif USING_STRINGBUILDER:
856
+ self._buffer = StringIO(ret)
857
+ return ret
858
+
859
+ def pack_map_pairs(self, pairs):
860
+ self._pack_map_pairs(len(pairs), pairs)
861
+ ret = self._buffer.getvalue()
862
+ if self._autoreset:
863
+ self._buffer = StringIO()
864
+ elif USING_STRINGBUILDER:
865
+ self._buffer = StringIO(ret)
866
+ return ret
867
+
868
+ def pack_array_header(self, n):
869
+ if n >= 2**32:
870
+ raise PackValueError
871
+ self._pack_array_header(n)
872
+ ret = self._buffer.getvalue()
873
+ if self._autoreset:
874
+ self._buffer = StringIO()
875
+ elif USING_STRINGBUILDER:
876
+ self._buffer = StringIO(ret)
877
+ return ret
878
+
879
+ def pack_map_header(self, n):
880
+ if n >= 2**32:
881
+ raise PackValueError
882
+ self._pack_map_header(n)
883
+ ret = self._buffer.getvalue()
884
+ if self._autoreset:
885
+ self._buffer = StringIO()
886
+ elif USING_STRINGBUILDER:
887
+ self._buffer = StringIO(ret)
888
+ return ret
889
+
890
+ def pack_ext_type(self, typecode, data):
891
+ if not isinstance(typecode, int):
892
+ raise TypeError("typecode must have int type.")
893
+ if not 0 <= typecode <= 127:
894
+ raise ValueError("typecode should be 0-127")
895
+ if not isinstance(data, bytes):
896
+ raise TypeError("data must have bytes type")
897
+ L = len(data)
898
+ if L > 0xffffffff:
899
+ raise PackValueError("Too large data")
900
+ if L == 1:
901
+ self._buffer.write(b'\xd4')
902
+ elif L == 2:
903
+ self._buffer.write(b'\xd5')
904
+ elif L == 4:
905
+ self._buffer.write(b'\xd6')
906
+ elif L == 8:
907
+ self._buffer.write(b'\xd7')
908
+ elif L == 16:
909
+ self._buffer.write(b'\xd8')
910
+ elif L <= 0xff:
911
+ self._buffer.write(b'\xc7' + struct.pack('B', L))
912
+ elif L <= 0xffff:
913
+ self._buffer.write(b'\xc8' + struct.pack('>H', L))
914
+ else:
915
+ self._buffer.write(b'\xc9' + struct.pack('>I', L))
916
+ self._buffer.write(struct.pack('B', typecode))
917
+ self._buffer.write(data)
918
+
919
+ def _pack_array_header(self, n):
920
+ if n <= 0x0f:
921
+ return self._buffer.write(struct.pack('B', 0x90 + n))
922
+ if n <= 0xffff:
923
+ return self._buffer.write(struct.pack(">BH", 0xdc, n))
924
+ if n <= 0xffffffff:
925
+ return self._buffer.write(struct.pack(">BI", 0xdd, n))
926
+ raise PackValueError("Array is too large")
927
+
928
+ def _pack_map_header(self, n):
929
+ if n <= 0x0f:
930
+ return self._buffer.write(struct.pack('B', 0x80 + n))
931
+ if n <= 0xffff:
932
+ return self._buffer.write(struct.pack(">BH", 0xde, n))
933
+ if n <= 0xffffffff:
934
+ return self._buffer.write(struct.pack(">BI", 0xdf, n))
935
+ raise PackValueError("Dict is too large")
936
+
937
+ def _pack_map_pairs(self, n, pairs, nest_limit=DEFAULT_RECURSE_LIMIT):
938
+ self._pack_map_header(n)
939
+ for (k, v) in pairs:
940
+ self._pack(k, nest_limit - 1)
941
+ self._pack(v, nest_limit - 1)
942
+
943
+ def _pack_raw_header(self, n):
944
+ if n <= 0x1f:
945
+ self._buffer.write(struct.pack('B', 0xa0 + n))
946
+ elif self._use_bin_type and n <= 0xff:
947
+ self._buffer.write(struct.pack('>BB', 0xd9, n))
948
+ elif n <= 0xffff:
949
+ self._buffer.write(struct.pack(">BH", 0xda, n))
950
+ elif n <= 0xffffffff:
951
+ self._buffer.write(struct.pack(">BI", 0xdb, n))
952
+ else:
953
+ raise PackValueError('Raw is too large')
954
+
955
+ def _pack_bin_header(self, n):
956
+ if not self._use_bin_type:
957
+ return self._pack_raw_header(n)
958
+ elif n <= 0xff:
959
+ return self._buffer.write(struct.pack('>BB', 0xc4, n))
960
+ elif n <= 0xffff:
961
+ return self._buffer.write(struct.pack(">BH", 0xc5, n))
962
+ elif n <= 0xffffffff:
963
+ return self._buffer.write(struct.pack(">BI", 0xc6, n))
964
+ else:
965
+ raise PackValueError('Bin is too large')
966
+
967
+ def bytes(self):
968
+ return self._buffer.getvalue()
969
+
970
+ def reset(self):
971
+ self._buffer = StringIO()