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,1104 @@
1
+ # Copyright 2015,2016 Nir Cohen
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ The ``distro`` package (``distro`` stands for Linux Distribution) provides
17
+ information about the Linux distribution it runs on, such as a reliable
18
+ machine-readable distro ID, or version information.
19
+
20
+ It is a renewed alternative implementation for Python's original
21
+ :py:func:`platform.linux_distribution` function, but it provides much more
22
+ functionality. An alternative implementation became necessary because Python
23
+ 3.5 deprecated this function, and Python 3.7 is expected to remove it
24
+ altogether. Its predecessor function :py:func:`platform.dist` was already
25
+ deprecated since Python 2.6 and is also expected to be removed in Python 3.7.
26
+ Still, there are many cases in which access to Linux distribution information
27
+ is needed. See `Python issue 1322 <https://bugs.python.org/issue1322>`_ for
28
+ more information.
29
+ """
30
+
31
+ import os
32
+ import re
33
+ import sys
34
+ import json
35
+ import shlex
36
+ import logging
37
+ import argparse
38
+ import subprocess
39
+
40
+
41
+ _UNIXCONFDIR = os.environ.get('UNIXCONFDIR', '/etc')
42
+ _OS_RELEASE_BASENAME = 'os-release'
43
+
44
+ #: Translation table for normalizing the "ID" attribute defined in os-release
45
+ #: files, for use by the :func:`distro.id` method.
46
+ #:
47
+ #: * Key: Value as defined in the os-release file, translated to lower case,
48
+ #: with blanks translated to underscores.
49
+ #:
50
+ #: * Value: Normalized value.
51
+ NORMALIZED_OS_ID = {}
52
+
53
+ #: Translation table for normalizing the "Distributor ID" attribute returned by
54
+ #: the lsb_release command, for use by the :func:`distro.id` method.
55
+ #:
56
+ #: * Key: Value as returned by the lsb_release command, translated to lower
57
+ #: case, with blanks translated to underscores.
58
+ #:
59
+ #: * Value: Normalized value.
60
+ NORMALIZED_LSB_ID = {
61
+ 'enterpriseenterprise': 'oracle', # Oracle Enterprise Linux
62
+ 'redhatenterpriseworkstation': 'rhel', # RHEL 6, 7 Workstation
63
+ 'redhatenterpriseserver': 'rhel', # RHEL 6, 7 Server
64
+ }
65
+
66
+ #: Translation table for normalizing the distro ID derived from the file name
67
+ #: of distro release files, for use by the :func:`distro.id` method.
68
+ #:
69
+ #: * Key: Value as derived from the file name of a distro release file,
70
+ #: translated to lower case, with blanks translated to underscores.
71
+ #:
72
+ #: * Value: Normalized value.
73
+ NORMALIZED_DISTRO_ID = {
74
+ 'redhat': 'rhel', # RHEL 6.x, 7.x
75
+ }
76
+
77
+ # Pattern for content of distro release file (reversed)
78
+ _DISTRO_RELEASE_CONTENT_REVERSED_PATTERN = re.compile(
79
+ r'(?:[^)]*\)(.*)\()? *(?:STL )?([\d.+\-a-z]*\d) *(?:esaeler *)?(.+)')
80
+
81
+ # Pattern for base file name of distro release file
82
+ _DISTRO_RELEASE_BASENAME_PATTERN = re.compile(
83
+ r'(\w+)[-_](release|version)$')
84
+
85
+ # Base file names to be ignored when searching for distro release file
86
+ _DISTRO_RELEASE_IGNORE_BASENAMES = (
87
+ 'debian_version',
88
+ 'lsb-release',
89
+ 'oem-release',
90
+ _OS_RELEASE_BASENAME,
91
+ 'system-release'
92
+ )
93
+
94
+
95
+ def linux_distribution(full_distribution_name=True):
96
+ """
97
+ Return information about the current Linux distribution as a tuple
98
+ ``(id_name, version, codename)`` with items as follows:
99
+
100
+ * ``id_name``: If *full_distribution_name* is false, the result of
101
+ :func:`distro.id`. Otherwise, the result of :func:`distro.name`.
102
+
103
+ * ``version``: The result of :func:`distro.version`.
104
+
105
+ * ``codename``: The result of :func:`distro.codename`.
106
+
107
+ The interface of this function is compatible with the original
108
+ :py:func:`platform.linux_distribution` function, supporting a subset of
109
+ its parameters.
110
+
111
+ The data it returns may not exactly be the same, because it uses more data
112
+ sources than the original function, and that may lead to different data if
113
+ the Linux distribution is not consistent across multiple data sources it
114
+ provides (there are indeed such distributions ...).
115
+
116
+ Another reason for differences is the fact that the :func:`distro.id`
117
+ method normalizes the distro ID string to a reliable machine-readable value
118
+ for a number of popular Linux distributions.
119
+ """
120
+ return _distro.linux_distribution(full_distribution_name)
121
+
122
+
123
+ def id():
124
+ """
125
+ Return the distro ID of the current Linux distribution, as a
126
+ machine-readable string.
127
+
128
+ For a number of Linux distributions, the returned distro ID value is
129
+ *reliable*, in the sense that it is documented and that it does not change
130
+ across releases of the distribution.
131
+
132
+ This package maintains the following reliable distro ID values:
133
+
134
+ ============== =========================================
135
+ Distro ID Distribution
136
+ ============== =========================================
137
+ "ubuntu" Ubuntu
138
+ "debian" Debian
139
+ "rhel" RedHat Enterprise Linux
140
+ "centos" CentOS
141
+ "fedora" Fedora
142
+ "sles" SUSE Linux Enterprise Server
143
+ "opensuse" openSUSE
144
+ "amazon" Amazon Linux
145
+ "arch" Arch Linux
146
+ "cloudlinux" CloudLinux OS
147
+ "exherbo" Exherbo Linux
148
+ "gentoo" GenToo Linux
149
+ "ibm_powerkvm" IBM PowerKVM
150
+ "kvmibm" KVM for IBM z Systems
151
+ "linuxmint" Linux Mint
152
+ "mageia" Mageia
153
+ "mandriva" Mandriva Linux
154
+ "parallels" Parallels
155
+ "pidora" Pidora
156
+ "raspbian" Raspbian
157
+ "oracle" Oracle Linux (and Oracle Enterprise Linux)
158
+ "scientific" Scientific Linux
159
+ "slackware" Slackware
160
+ "xenserver" XenServer
161
+ ============== =========================================
162
+
163
+ If you have a need to get distros for reliable IDs added into this set,
164
+ or if you find that the :func:`distro.id` function returns a different
165
+ distro ID for one of the listed distros, please create an issue in the
166
+ `distro issue tracker`_.
167
+
168
+ **Lookup hierarchy and transformations:**
169
+
170
+ First, the ID is obtained from the following sources, in the specified
171
+ order. The first available and non-empty value is used:
172
+
173
+ * the value of the "ID" attribute of the os-release file,
174
+
175
+ * the value of the "Distributor ID" attribute returned by the lsb_release
176
+ command,
177
+
178
+ * the first part of the file name of the distro release file,
179
+
180
+ The so determined ID value then passes the following transformations,
181
+ before it is returned by this method:
182
+
183
+ * it is translated to lower case,
184
+
185
+ * blanks (which should not be there anyway) are translated to underscores,
186
+
187
+ * a normalization of the ID is performed, based upon
188
+ `normalization tables`_. The purpose of this normalization is to ensure
189
+ that the ID is as reliable as possible, even across incompatible changes
190
+ in the Linux distributions. A common reason for an incompatible change is
191
+ the addition of an os-release file, or the addition of the lsb_release
192
+ command, with ID values that differ from what was previously determined
193
+ from the distro release file name.
194
+ """
195
+ return _distro.id()
196
+
197
+
198
+ def name(pretty=False):
199
+ """
200
+ Return the name of the current Linux distribution, as a human-readable
201
+ string.
202
+
203
+ If *pretty* is false, the name is returned without version or codename.
204
+ (e.g. "CentOS Linux")
205
+
206
+ If *pretty* is true, the version and codename are appended.
207
+ (e.g. "CentOS Linux 7.1.1503 (Core)")
208
+
209
+ **Lookup hierarchy:**
210
+
211
+ The name is obtained from the following sources, in the specified order.
212
+ The first available and non-empty value is used:
213
+
214
+ * If *pretty* is false:
215
+
216
+ - the value of the "NAME" attribute of the os-release file,
217
+
218
+ - the value of the "Distributor ID" attribute returned by the lsb_release
219
+ command,
220
+
221
+ - the value of the "<name>" field of the distro release file.
222
+
223
+ * If *pretty* is true:
224
+
225
+ - the value of the "PRETTY_NAME" attribute of the os-release file,
226
+
227
+ - the value of the "Description" attribute returned by the lsb_release
228
+ command,
229
+
230
+ - the value of the "<name>" field of the distro release file, appended
231
+ with the value of the pretty version ("<version_id>" and "<codename>"
232
+ fields) of the distro release file, if available.
233
+ """
234
+ return _distro.name(pretty)
235
+
236
+
237
+ def version(pretty=False, best=False):
238
+ """
239
+ Return the version of the current Linux distribution, as a human-readable
240
+ string.
241
+
242
+ If *pretty* is false, the version is returned without codename (e.g.
243
+ "7.0").
244
+
245
+ If *pretty* is true, the codename in parenthesis is appended, if the
246
+ codename is non-empty (e.g. "7.0 (Maipo)").
247
+
248
+ Some distributions provide version numbers with different precisions in
249
+ the different sources of distribution information. Examining the different
250
+ sources in a fixed priority order does not always yield the most precise
251
+ version (e.g. for Debian 8.2, or CentOS 7.1).
252
+
253
+ The *best* parameter can be used to control the approach for the returned
254
+ version:
255
+
256
+ If *best* is false, the first non-empty version number in priority order of
257
+ the examined sources is returned.
258
+
259
+ If *best* is true, the most precise version number out of all examined
260
+ sources is returned.
261
+
262
+ **Lookup hierarchy:**
263
+
264
+ In all cases, the version number is obtained from the following sources.
265
+ If *best* is false, this order represents the priority order:
266
+
267
+ * the value of the "VERSION_ID" attribute of the os-release file,
268
+ * the value of the "Release" attribute returned by the lsb_release
269
+ command,
270
+ * the version number parsed from the "<version_id>" field of the first line
271
+ of the distro release file,
272
+ * the version number parsed from the "PRETTY_NAME" attribute of the
273
+ os-release file, if it follows the format of the distro release files.
274
+ * the version number parsed from the "Description" attribute returned by
275
+ the lsb_release command, if it follows the format of the distro release
276
+ files.
277
+ """
278
+ return _distro.version(pretty, best)
279
+
280
+
281
+ def version_parts(best=False):
282
+ """
283
+ Return the version of the current Linux distribution as a tuple
284
+ ``(major, minor, build_number)`` with items as follows:
285
+
286
+ * ``major``: The result of :func:`distro.major_version`.
287
+
288
+ * ``minor``: The result of :func:`distro.minor_version`.
289
+
290
+ * ``build_number``: The result of :func:`distro.build_number`.
291
+
292
+ For a description of the *best* parameter, see the :func:`distro.version`
293
+ method.
294
+ """
295
+ return _distro.version_parts(best)
296
+
297
+
298
+ def major_version(best=False):
299
+ """
300
+ Return the major version of the current Linux distribution, as a string,
301
+ if provided.
302
+ Otherwise, the empty string is returned. The major version is the first
303
+ part of the dot-separated version string.
304
+
305
+ For a description of the *best* parameter, see the :func:`distro.version`
306
+ method.
307
+ """
308
+ return _distro.major_version(best)
309
+
310
+
311
+ def minor_version(best=False):
312
+ """
313
+ Return the minor version of the current Linux distribution, as a string,
314
+ if provided.
315
+ Otherwise, the empty string is returned. The minor version is the second
316
+ part of the dot-separated version string.
317
+
318
+ For a description of the *best* parameter, see the :func:`distro.version`
319
+ method.
320
+ """
321
+ return _distro.minor_version(best)
322
+
323
+
324
+ def build_number(best=False):
325
+ """
326
+ Return the build number of the current Linux distribution, as a string,
327
+ if provided.
328
+ Otherwise, the empty string is returned. The build number is the third part
329
+ of the dot-separated version string.
330
+
331
+ For a description of the *best* parameter, see the :func:`distro.version`
332
+ method.
333
+ """
334
+ return _distro.build_number(best)
335
+
336
+
337
+ def like():
338
+ """
339
+ Return a space-separated list of distro IDs of distributions that are
340
+ closely related to the current Linux distribution in regards to packaging
341
+ and programming interfaces, for example distributions the current
342
+ distribution is a derivative from.
343
+
344
+ **Lookup hierarchy:**
345
+
346
+ This information item is only provided by the os-release file.
347
+ For details, see the description of the "ID_LIKE" attribute in the
348
+ `os-release man page
349
+ <http://www.freedesktop.org/software/systemd/man/os-release.html>`_.
350
+ """
351
+ return _distro.like()
352
+
353
+
354
+ def codename():
355
+ """
356
+ Return the codename for the release of the current Linux distribution,
357
+ as a string.
358
+
359
+ If the distribution does not have a codename, an empty string is returned.
360
+
361
+ Note that the returned codename is not always really a codename. For
362
+ example, openSUSE returns "x86_64". This function does not handle such
363
+ cases in any special way and just returns the string it finds, if any.
364
+
365
+ **Lookup hierarchy:**
366
+
367
+ * the codename within the "VERSION" attribute of the os-release file, if
368
+ provided,
369
+
370
+ * the value of the "Codename" attribute returned by the lsb_release
371
+ command,
372
+
373
+ * the value of the "<codename>" field of the distro release file.
374
+ """
375
+ return _distro.codename()
376
+
377
+
378
+ def info(pretty=False, best=False):
379
+ """
380
+ Return certain machine-readable information items about the current Linux
381
+ distribution in a dictionary, as shown in the following example:
382
+
383
+ .. sourcecode:: python
384
+
385
+ {
386
+ 'id': 'rhel',
387
+ 'version': '7.0',
388
+ 'version_parts': {
389
+ 'major': '7',
390
+ 'minor': '0',
391
+ 'build_number': ''
392
+ },
393
+ 'like': 'fedora',
394
+ 'codename': 'Maipo'
395
+ }
396
+
397
+ The dictionary structure and keys are always the same, regardless of which
398
+ information items are available in the underlying data sources. The values
399
+ for the various keys are as follows:
400
+
401
+ * ``id``: The result of :func:`distro.id`.
402
+
403
+ * ``version``: The result of :func:`distro.version`.
404
+
405
+ * ``version_parts -> major``: The result of :func:`distro.major_version`.
406
+
407
+ * ``version_parts -> minor``: The result of :func:`distro.minor_version`.
408
+
409
+ * ``version_parts -> build_number``: The result of
410
+ :func:`distro.build_number`.
411
+
412
+ * ``like``: The result of :func:`distro.like`.
413
+
414
+ * ``codename``: The result of :func:`distro.codename`.
415
+
416
+ For a description of the *pretty* and *best* parameters, see the
417
+ :func:`distro.version` method.
418
+ """
419
+ return _distro.info(pretty, best)
420
+
421
+
422
+ def os_release_info():
423
+ """
424
+ Return a dictionary containing key-value pairs for the information items
425
+ from the os-release file data source of the current Linux distribution.
426
+
427
+ See `os-release file`_ for details about these information items.
428
+ """
429
+ return _distro.os_release_info()
430
+
431
+
432
+ def lsb_release_info():
433
+ """
434
+ Return a dictionary containing key-value pairs for the information items
435
+ from the lsb_release command data source of the current Linux distribution.
436
+
437
+ See `lsb_release command output`_ for details about these information
438
+ items.
439
+ """
440
+ return _distro.lsb_release_info()
441
+
442
+
443
+ def distro_release_info():
444
+ """
445
+ Return a dictionary containing key-value pairs for the information items
446
+ from the distro release file data source of the current Linux distribution.
447
+
448
+ See `distro release file`_ for details about these information items.
449
+ """
450
+ return _distro.distro_release_info()
451
+
452
+
453
+ def os_release_attr(attribute):
454
+ """
455
+ Return a single named information item from the os-release file data source
456
+ of the current Linux distribution.
457
+
458
+ Parameters:
459
+
460
+ * ``attribute`` (string): Key of the information item.
461
+
462
+ Returns:
463
+
464
+ * (string): Value of the information item, if the item exists.
465
+ The empty string, if the item does not exist.
466
+
467
+ See `os-release file`_ for details about these information items.
468
+ """
469
+ return _distro.os_release_attr(attribute)
470
+
471
+
472
+ def lsb_release_attr(attribute):
473
+ """
474
+ Return a single named information item from the lsb_release command output
475
+ data source of the current Linux distribution.
476
+
477
+ Parameters:
478
+
479
+ * ``attribute`` (string): Key of the information item.
480
+
481
+ Returns:
482
+
483
+ * (string): Value of the information item, if the item exists.
484
+ The empty string, if the item does not exist.
485
+
486
+ See `lsb_release command output`_ for details about these information
487
+ items.
488
+ """
489
+ return _distro.lsb_release_attr(attribute)
490
+
491
+
492
+ def distro_release_attr(attribute):
493
+ """
494
+ Return a single named information item from the distro release file
495
+ data source of the current Linux distribution.
496
+
497
+ Parameters:
498
+
499
+ * ``attribute`` (string): Key of the information item.
500
+
501
+ Returns:
502
+
503
+ * (string): Value of the information item, if the item exists.
504
+ The empty string, if the item does not exist.
505
+
506
+ See `distro release file`_ for details about these information items.
507
+ """
508
+ return _distro.distro_release_attr(attribute)
509
+
510
+
511
+ class cached_property(object):
512
+ """A version of @property which caches the value. On access, it calls the
513
+ underlying function and sets the value in `__dict__` so future accesses
514
+ will not re-call the property.
515
+ """
516
+ def __init__(self, f):
517
+ self._fname = f.__name__
518
+ self._f = f
519
+
520
+ def __get__(self, obj, owner):
521
+ assert obj is not None, 'call {} on an instance'.format(self._fname)
522
+ ret = obj.__dict__[self._fname] = self._f(obj)
523
+ return ret
524
+
525
+
526
+ class LinuxDistribution(object):
527
+ """
528
+ Provides information about a Linux distribution.
529
+
530
+ This package creates a private module-global instance of this class with
531
+ default initialization arguments, that is used by the
532
+ `consolidated accessor functions`_ and `single source accessor functions`_.
533
+ By using default initialization arguments, that module-global instance
534
+ returns data about the current Linux distribution (i.e. the distro this
535
+ package runs on).
536
+
537
+ Normally, it is not necessary to create additional instances of this class.
538
+ However, in situations where control is needed over the exact data sources
539
+ that are used, instances of this class can be created with a specific
540
+ distro release file, or a specific os-release file, or without invoking the
541
+ lsb_release command.
542
+ """
543
+
544
+ def __init__(self,
545
+ include_lsb=True,
546
+ os_release_file='',
547
+ distro_release_file=''):
548
+ """
549
+ The initialization method of this class gathers information from the
550
+ available data sources, and stores that in private instance attributes.
551
+ Subsequent access to the information items uses these private instance
552
+ attributes, so that the data sources are read only once.
553
+
554
+ Parameters:
555
+
556
+ * ``include_lsb`` (bool): Controls whether the
557
+ `lsb_release command output`_ is included as a data source.
558
+
559
+ If the lsb_release command is not available in the program execution
560
+ path, the data source for the lsb_release command will be empty.
561
+
562
+ * ``os_release_file`` (string): The path name of the
563
+ `os-release file`_ that is to be used as a data source.
564
+
565
+ An empty string (the default) will cause the default path name to
566
+ be used (see `os-release file`_ for details).
567
+
568
+ If the specified or defaulted os-release file does not exist, the
569
+ data source for the os-release file will be empty.
570
+
571
+ * ``distro_release_file`` (string): The path name of the
572
+ `distro release file`_ that is to be used as a data source.
573
+
574
+ An empty string (the default) will cause a default search algorithm
575
+ to be used (see `distro release file`_ for details).
576
+
577
+ If the specified distro release file does not exist, or if no default
578
+ distro release file can be found, the data source for the distro
579
+ release file will be empty.
580
+
581
+ Public instance attributes:
582
+
583
+ * ``os_release_file`` (string): The path name of the
584
+ `os-release file`_ that is actually used as a data source. The
585
+ empty string if no distro release file is used as a data source.
586
+
587
+ * ``distro_release_file`` (string): The path name of the
588
+ `distro release file`_ that is actually used as a data source. The
589
+ empty string if no distro release file is used as a data source.
590
+
591
+ * ``include_lsb`` (bool): The result of the ``include_lsb`` parameter.
592
+ This controls whether the lsb information will be loaded.
593
+
594
+ Raises:
595
+
596
+ * :py:exc:`IOError`: Some I/O issue with an os-release file or distro
597
+ release file.
598
+
599
+ * :py:exc:`subprocess.CalledProcessError`: The lsb_release command had
600
+ some issue (other than not being available in the program execution
601
+ path).
602
+
603
+ * :py:exc:`UnicodeError`: A data source has unexpected characters or
604
+ uses an unexpected encoding.
605
+ """
606
+ self.os_release_file = os_release_file or \
607
+ os.path.join(_UNIXCONFDIR, _OS_RELEASE_BASENAME)
608
+ self.distro_release_file = distro_release_file or '' # updated later
609
+ self.include_lsb = include_lsb
610
+
611
+ def __repr__(self):
612
+ """Return repr of all info
613
+ """
614
+ return \
615
+ "LinuxDistribution(" \
616
+ "os_release_file={self.os_release_file!r}, " \
617
+ "distro_release_file={self.distro_release_file!r}, " \
618
+ "include_lsb={self.include_lsb!r}, " \
619
+ "_os_release_info={self._os_release_info!r}, " \
620
+ "_lsb_release_info={self._lsb_release_info!r}, " \
621
+ "_distro_release_info={self._distro_release_info!r})".format(
622
+ self=self)
623
+
624
+ def linux_distribution(self, full_distribution_name=True):
625
+ """
626
+ Return information about the Linux distribution that is compatible
627
+ with Python's :func:`platform.linux_distribution`, supporting a subset
628
+ of its parameters.
629
+
630
+ For details, see :func:`distro.linux_distribution`.
631
+ """
632
+ return (
633
+ self.name() if full_distribution_name else self.id(),
634
+ self.version(),
635
+ self.codename()
636
+ )
637
+
638
+ def id(self):
639
+ """Return the distro ID of the Linux distribution, as a string.
640
+
641
+ For details, see :func:`distro.id`.
642
+ """
643
+ def normalize(distro_id, table):
644
+ distro_id = distro_id.lower().replace(' ', '_')
645
+ return table.get(distro_id, distro_id)
646
+
647
+ distro_id = self.os_release_attr('id')
648
+ if distro_id:
649
+ return normalize(distro_id, NORMALIZED_OS_ID)
650
+
651
+ distro_id = self.lsb_release_attr('distributor_id')
652
+ if distro_id:
653
+ return normalize(distro_id, NORMALIZED_LSB_ID)
654
+
655
+ distro_id = self.distro_release_attr('id')
656
+ if distro_id:
657
+ return normalize(distro_id, NORMALIZED_DISTRO_ID)
658
+
659
+ return ''
660
+
661
+ def name(self, pretty=False):
662
+ """
663
+ Return the name of the Linux distribution, as a string.
664
+
665
+ For details, see :func:`distro.name`.
666
+ """
667
+ name = self.os_release_attr('name') \
668
+ or self.lsb_release_attr('distributor_id') \
669
+ or self.distro_release_attr('name')
670
+ if pretty:
671
+ name = self.os_release_attr('pretty_name') \
672
+ or self.lsb_release_attr('description')
673
+ if not name:
674
+ name = self.distro_release_attr('name')
675
+ version = self.version(pretty=True)
676
+ if version:
677
+ name = name + ' ' + version
678
+ return name or ''
679
+
680
+ def version(self, pretty=False, best=False):
681
+ """
682
+ Return the version of the Linux distribution, as a string.
683
+
684
+ For details, see :func:`distro.version`.
685
+ """
686
+ versions = [
687
+ self.os_release_attr('version_id'),
688
+ self.lsb_release_attr('release'),
689
+ self.distro_release_attr('version_id'),
690
+ self._parse_distro_release_content(
691
+ self.os_release_attr('pretty_name')).get('version_id', ''),
692
+ self._parse_distro_release_content(
693
+ self.lsb_release_attr('description')).get('version_id', '')
694
+ ]
695
+ version = ''
696
+ if best:
697
+ # This algorithm uses the last version in priority order that has
698
+ # the best precision. If the versions are not in conflict, that
699
+ # does not matter; otherwise, using the last one instead of the
700
+ # first one might be considered a surprise.
701
+ for v in versions:
702
+ if v.count(".") > version.count(".") or version == '':
703
+ version = v
704
+ else:
705
+ for v in versions:
706
+ if v != '':
707
+ version = v
708
+ break
709
+ if pretty and version and self.codename():
710
+ version = u'{0} ({1})'.format(version, self.codename())
711
+ return version
712
+
713
+ def version_parts(self, best=False):
714
+ """
715
+ Return the version of the Linux distribution, as a tuple of version
716
+ numbers.
717
+
718
+ For details, see :func:`distro.version_parts`.
719
+ """
720
+ version_str = self.version(best=best)
721
+ if version_str:
722
+ version_regex = re.compile(r'(\d+)\.?(\d+)?\.?(\d+)?')
723
+ matches = version_regex.match(version_str)
724
+ if matches:
725
+ major, minor, build_number = matches.groups()
726
+ return major, minor or '', build_number or ''
727
+ return '', '', ''
728
+
729
+ def major_version(self, best=False):
730
+ """
731
+ Return the major version number of the current distribution.
732
+
733
+ For details, see :func:`distro.major_version`.
734
+ """
735
+ return self.version_parts(best)[0]
736
+
737
+ def minor_version(self, best=False):
738
+ """
739
+ Return the minor version number of the Linux distribution.
740
+
741
+ For details, see :func:`distro.minor_version`.
742
+ """
743
+ return self.version_parts(best)[1]
744
+
745
+ def build_number(self, best=False):
746
+ """
747
+ Return the build number of the Linux distribution.
748
+
749
+ For details, see :func:`distro.build_number`.
750
+ """
751
+ return self.version_parts(best)[2]
752
+
753
+ def like(self):
754
+ """
755
+ Return the IDs of distributions that are like the Linux distribution.
756
+
757
+ For details, see :func:`distro.like`.
758
+ """
759
+ return self.os_release_attr('id_like') or ''
760
+
761
+ def codename(self):
762
+ """
763
+ Return the codename of the Linux distribution.
764
+
765
+ For details, see :func:`distro.codename`.
766
+ """
767
+ return self.os_release_attr('codename') \
768
+ or self.lsb_release_attr('codename') \
769
+ or self.distro_release_attr('codename') \
770
+ or ''
771
+
772
+ def info(self, pretty=False, best=False):
773
+ """
774
+ Return certain machine-readable information about the Linux
775
+ distribution.
776
+
777
+ For details, see :func:`distro.info`.
778
+ """
779
+ return dict(
780
+ id=self.id(),
781
+ version=self.version(pretty, best),
782
+ version_parts=dict(
783
+ major=self.major_version(best),
784
+ minor=self.minor_version(best),
785
+ build_number=self.build_number(best)
786
+ ),
787
+ like=self.like(),
788
+ codename=self.codename(),
789
+ )
790
+
791
+ def os_release_info(self):
792
+ """
793
+ Return a dictionary containing key-value pairs for the information
794
+ items from the os-release file data source of the Linux distribution.
795
+
796
+ For details, see :func:`distro.os_release_info`.
797
+ """
798
+ return self._os_release_info
799
+
800
+ def lsb_release_info(self):
801
+ """
802
+ Return a dictionary containing key-value pairs for the information
803
+ items from the lsb_release command data source of the Linux
804
+ distribution.
805
+
806
+ For details, see :func:`distro.lsb_release_info`.
807
+ """
808
+ return self._lsb_release_info
809
+
810
+ def distro_release_info(self):
811
+ """
812
+ Return a dictionary containing key-value pairs for the information
813
+ items from the distro release file data source of the Linux
814
+ distribution.
815
+
816
+ For details, see :func:`distro.distro_release_info`.
817
+ """
818
+ return self._distro_release_info
819
+
820
+ def os_release_attr(self, attribute):
821
+ """
822
+ Return a single named information item from the os-release file data
823
+ source of the Linux distribution.
824
+
825
+ For details, see :func:`distro.os_release_attr`.
826
+ """
827
+ return self._os_release_info.get(attribute, '')
828
+
829
+ def lsb_release_attr(self, attribute):
830
+ """
831
+ Return a single named information item from the lsb_release command
832
+ output data source of the Linux distribution.
833
+
834
+ For details, see :func:`distro.lsb_release_attr`.
835
+ """
836
+ return self._lsb_release_info.get(attribute, '')
837
+
838
+ def distro_release_attr(self, attribute):
839
+ """
840
+ Return a single named information item from the distro release file
841
+ data source of the Linux distribution.
842
+
843
+ For details, see :func:`distro.distro_release_attr`.
844
+ """
845
+ return self._distro_release_info.get(attribute, '')
846
+
847
+ @cached_property
848
+ def _os_release_info(self):
849
+ """
850
+ Get the information items from the specified os-release file.
851
+
852
+ Returns:
853
+ A dictionary containing all information items.
854
+ """
855
+ if os.path.isfile(self.os_release_file):
856
+ with open(self.os_release_file) as release_file:
857
+ return self._parse_os_release_content(release_file)
858
+ return {}
859
+
860
+ @staticmethod
861
+ def _parse_os_release_content(lines):
862
+ """
863
+ Parse the lines of an os-release file.
864
+
865
+ Parameters:
866
+
867
+ * lines: Iterable through the lines in the os-release file.
868
+ Each line must be a unicode string or a UTF-8 encoded byte
869
+ string.
870
+
871
+ Returns:
872
+ A dictionary containing all information items.
873
+ """
874
+ props = {}
875
+ lexer = shlex.shlex(lines, posix=True)
876
+ lexer.whitespace_split = True
877
+
878
+ # The shlex module defines its `wordchars` variable using literals,
879
+ # making it dependent on the encoding of the Python source file.
880
+ # In Python 2.6 and 2.7, the shlex source file is encoded in
881
+ # 'iso-8859-1', and the `wordchars` variable is defined as a byte
882
+ # string. This causes a UnicodeDecodeError to be raised when the
883
+ # parsed content is a unicode object. The following fix resolves that
884
+ # (... but it should be fixed in shlex...):
885
+ if sys.version_info[0] == 2 and isinstance(lexer.wordchars, bytes):
886
+ lexer.wordchars = lexer.wordchars.decode('iso-8859-1')
887
+
888
+ tokens = list(lexer)
889
+ for token in tokens:
890
+ # At this point, all shell-like parsing has been done (i.e.
891
+ # comments processed, quotes and backslash escape sequences
892
+ # processed, multi-line values assembled, trailing newlines
893
+ # stripped, etc.), so the tokens are now either:
894
+ # * variable assignments: var=value
895
+ # * commands or their arguments (not allowed in os-release)
896
+ if '=' in token:
897
+ k, v = token.split('=', 1)
898
+ if isinstance(v, bytes):
899
+ v = v.decode('utf-8')
900
+ props[k.lower()] = v
901
+ if k == 'VERSION':
902
+ # this handles cases in which the codename is in
903
+ # the `(CODENAME)` (rhel, centos, fedora) format
904
+ # or in the `, CODENAME` format (Ubuntu).
905
+ codename = re.search(r'(\(\D+\))|,(\s+)?\D+', v)
906
+ if codename:
907
+ codename = codename.group()
908
+ codename = codename.strip('()')
909
+ codename = codename.strip(',')
910
+ codename = codename.strip()
911
+ # codename appears within paranthese.
912
+ props['codename'] = codename
913
+ else:
914
+ props['codename'] = ''
915
+ else:
916
+ # Ignore any tokens that are not variable assignments
917
+ pass
918
+ return props
919
+
920
+ @cached_property
921
+ def _lsb_release_info(self):
922
+ """
923
+ Get the information items from the lsb_release command output.
924
+
925
+ Returns:
926
+ A dictionary containing all information items.
927
+ """
928
+ if not self.include_lsb:
929
+ return {}
930
+ with open(os.devnull, 'w') as devnull:
931
+ try:
932
+ cmd = ('lsb_release', '-a')
933
+ stdout = subprocess.check_output(cmd, stderr=devnull)
934
+ except OSError: # Command not found
935
+ return {}
936
+ content = stdout.decode(sys.getfilesystemencoding()).splitlines()
937
+ return self._parse_lsb_release_content(content)
938
+
939
+ @staticmethod
940
+ def _parse_lsb_release_content(lines):
941
+ """
942
+ Parse the output of the lsb_release command.
943
+
944
+ Parameters:
945
+
946
+ * lines: Iterable through the lines of the lsb_release output.
947
+ Each line must be a unicode string or a UTF-8 encoded byte
948
+ string.
949
+
950
+ Returns:
951
+ A dictionary containing all information items.
952
+ """
953
+ props = {}
954
+ for line in lines:
955
+ kv = line.strip('\n').split(':', 1)
956
+ if len(kv) != 2:
957
+ # Ignore lines without colon.
958
+ continue
959
+ k, v = kv
960
+ props.update({k.replace(' ', '_').lower(): v.strip()})
961
+ return props
962
+
963
+ @cached_property
964
+ def _distro_release_info(self):
965
+ """
966
+ Get the information items from the specified distro release file.
967
+
968
+ Returns:
969
+ A dictionary containing all information items.
970
+ """
971
+ if self.distro_release_file:
972
+ # If it was specified, we use it and parse what we can, even if
973
+ # its file name or content does not match the expected pattern.
974
+ distro_info = self._parse_distro_release_file(
975
+ self.distro_release_file)
976
+ basename = os.path.basename(self.distro_release_file)
977
+ # The file name pattern for user-specified distro release files
978
+ # is somewhat more tolerant (compared to when searching for the
979
+ # file), because we want to use what was specified as best as
980
+ # possible.
981
+ match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename)
982
+ if match:
983
+ distro_info['id'] = match.group(1)
984
+ return distro_info
985
+ else:
986
+ try:
987
+ basenames = os.listdir(_UNIXCONFDIR)
988
+ # We sort for repeatability in cases where there are multiple
989
+ # distro specific files; e.g. CentOS, Oracle, Enterprise all
990
+ # containing `redhat-release` on top of their own.
991
+ basenames.sort()
992
+ except OSError:
993
+ # This may occur when /etc is not readable but we can't be
994
+ # sure about the *-release files. Check common entries of
995
+ # /etc for information. If they turn out to not be there the
996
+ # error is handled in `_parse_distro_release_file()`.
997
+ basenames = ['SuSE-release',
998
+ 'arch-release',
999
+ 'base-release',
1000
+ 'centos-release',
1001
+ 'fedora-release',
1002
+ 'gentoo-release',
1003
+ 'mageia-release',
1004
+ 'mandrake-release',
1005
+ 'mandriva-release',
1006
+ 'mandrivalinux-release',
1007
+ 'manjaro-release',
1008
+ 'oracle-release',
1009
+ 'redhat-release',
1010
+ 'sl-release',
1011
+ 'slackware-version']
1012
+ for basename in basenames:
1013
+ if basename in _DISTRO_RELEASE_IGNORE_BASENAMES:
1014
+ continue
1015
+ match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename)
1016
+ if match:
1017
+ filepath = os.path.join(_UNIXCONFDIR, basename)
1018
+ distro_info = self._parse_distro_release_file(filepath)
1019
+ if 'name' in distro_info:
1020
+ # The name is always present if the pattern matches
1021
+ self.distro_release_file = filepath
1022
+ distro_info['id'] = match.group(1)
1023
+ return distro_info
1024
+ return {}
1025
+
1026
+ def _parse_distro_release_file(self, filepath):
1027
+ """
1028
+ Parse a distro release file.
1029
+
1030
+ Parameters:
1031
+
1032
+ * filepath: Path name of the distro release file.
1033
+
1034
+ Returns:
1035
+ A dictionary containing all information items.
1036
+ """
1037
+ try:
1038
+ with open(filepath) as fp:
1039
+ # Only parse the first line. For instance, on SLES there
1040
+ # are multiple lines. We don't want them...
1041
+ return self._parse_distro_release_content(fp.readline())
1042
+ except (OSError, IOError):
1043
+ # Ignore not being able to read a specific, seemingly version
1044
+ # related file.
1045
+ # See https://github.com/nir0s/distro/issues/162
1046
+ return {}
1047
+
1048
+ @staticmethod
1049
+ def _parse_distro_release_content(line):
1050
+ """
1051
+ Parse a line from a distro release file.
1052
+
1053
+ Parameters:
1054
+ * line: Line from the distro release file. Must be a unicode string
1055
+ or a UTF-8 encoded byte string.
1056
+
1057
+ Returns:
1058
+ A dictionary containing all information items.
1059
+ """
1060
+ if isinstance(line, bytes):
1061
+ line = line.decode('utf-8')
1062
+ matches = _DISTRO_RELEASE_CONTENT_REVERSED_PATTERN.match(
1063
+ line.strip()[::-1])
1064
+ distro_info = {}
1065
+ if matches:
1066
+ # regexp ensures non-None
1067
+ distro_info['name'] = matches.group(3)[::-1]
1068
+ if matches.group(2):
1069
+ distro_info['version_id'] = matches.group(2)[::-1]
1070
+ if matches.group(1):
1071
+ distro_info['codename'] = matches.group(1)[::-1]
1072
+ elif line:
1073
+ distro_info['name'] = line.strip()
1074
+ return distro_info
1075
+
1076
+
1077
+ _distro = LinuxDistribution()
1078
+
1079
+
1080
+ def main():
1081
+ logger = logging.getLogger(__name__)
1082
+ logger.setLevel(logging.DEBUG)
1083
+ logger.addHandler(logging.StreamHandler(sys.stdout))
1084
+
1085
+ parser = argparse.ArgumentParser(description="Linux distro info tool")
1086
+ parser.add_argument(
1087
+ '--json',
1088
+ '-j',
1089
+ help="Output in machine readable format",
1090
+ action="store_true")
1091
+ args = parser.parse_args()
1092
+
1093
+ if args.json:
1094
+ logger.info(json.dumps(info(), indent=4, sort_keys=True))
1095
+ else:
1096
+ logger.info('Name: %s', name(pretty=True))
1097
+ distribution_version = version(pretty=True)
1098
+ logger.info('Version: %s', distribution_version)
1099
+ distribution_codename = codename()
1100
+ logger.info('Codename: %s', distribution_codename)
1101
+
1102
+
1103
+ if __name__ == '__main__':
1104
+ main()