gitlab-pygments.rb 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (399) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +2 -0
  3. data/README.md +91 -0
  4. data/Rakefile +78 -0
  5. data/bench.rb +22 -0
  6. data/cache-lexers.rb +8 -0
  7. data/lexers +0 -0
  8. data/lib/pygments/lexer.rb +148 -0
  9. data/lib/pygments/mentos.py +344 -0
  10. data/lib/pygments/popen.rb +389 -0
  11. data/lib/pygments/version.rb +3 -0
  12. data/lib/pygments.rb +8 -0
  13. data/pygments.rb.gemspec +24 -0
  14. data/test/test_data.c +2581 -0
  15. data/test/test_data.py +514 -0
  16. data/test/test_data_generated +2582 -0
  17. data/test/test_pygments.rb +276 -0
  18. data/vendor/custom_formatters/gitlab.py +171 -0
  19. data/vendor/custom_lexers/github.py +362 -0
  20. data/vendor/pygments-main/AUTHORS +115 -0
  21. data/vendor/pygments-main/CHANGES +762 -0
  22. data/vendor/pygments-main/LICENSE +25 -0
  23. data/vendor/pygments-main/MANIFEST.in +6 -0
  24. data/vendor/pygments-main/Makefile +59 -0
  25. data/vendor/pygments-main/REVISION +1 -0
  26. data/vendor/pygments-main/TODO +15 -0
  27. data/vendor/pygments-main/docs/generate.py +472 -0
  28. data/vendor/pygments-main/docs/pygmentize.1 +94 -0
  29. data/vendor/pygments-main/docs/src/api.txt +270 -0
  30. data/vendor/pygments-main/docs/src/authors.txt +5 -0
  31. data/vendor/pygments-main/docs/src/changelog.txt +5 -0
  32. data/vendor/pygments-main/docs/src/cmdline.txt +147 -0
  33. data/vendor/pygments-main/docs/src/filterdevelopment.txt +70 -0
  34. data/vendor/pygments-main/docs/src/filters.txt +42 -0
  35. data/vendor/pygments-main/docs/src/formatterdevelopment.txt +169 -0
  36. data/vendor/pygments-main/docs/src/formatters.txt +48 -0
  37. data/vendor/pygments-main/docs/src/index.txt +69 -0
  38. data/vendor/pygments-main/docs/src/installation.txt +71 -0
  39. data/vendor/pygments-main/docs/src/integrate.txt +43 -0
  40. data/vendor/pygments-main/docs/src/lexerdevelopment.txt +551 -0
  41. data/vendor/pygments-main/docs/src/lexers.txt +67 -0
  42. data/vendor/pygments-main/docs/src/moinmoin.txt +39 -0
  43. data/vendor/pygments-main/docs/src/plugins.txt +93 -0
  44. data/vendor/pygments-main/docs/src/quickstart.txt +202 -0
  45. data/vendor/pygments-main/docs/src/rstdirective.txt +22 -0
  46. data/vendor/pygments-main/docs/src/styles.txt +143 -0
  47. data/vendor/pygments-main/docs/src/tokens.txt +349 -0
  48. data/vendor/pygments-main/docs/src/unicode.txt +49 -0
  49. data/vendor/pygments-main/external/markdown-processor.py +67 -0
  50. data/vendor/pygments-main/external/moin-parser.py +112 -0
  51. data/vendor/pygments-main/external/pygments.bashcomp +38 -0
  52. data/vendor/pygments-main/external/rst-directive-old.py +77 -0
  53. data/vendor/pygments-main/external/rst-directive.py +83 -0
  54. data/vendor/pygments-main/ez_setup.py +276 -0
  55. data/vendor/pygments-main/pygmentize +7 -0
  56. data/vendor/pygments-main/pygments/__init__.py +91 -0
  57. data/vendor/pygments-main/pygments/cmdline.py +433 -0
  58. data/vendor/pygments-main/pygments/console.py +74 -0
  59. data/vendor/pygments-main/pygments/filter.py +74 -0
  60. data/vendor/pygments-main/pygments/filters/__init__.py +357 -0
  61. data/vendor/pygments-main/pygments/formatter.py +92 -0
  62. data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
  63. data/vendor/pygments-main/pygments/formatters/_mapping.py +94 -0
  64. data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
  65. data/vendor/pygments-main/pygments/formatters/gitlab.py +171 -0
  66. data/vendor/pygments-main/pygments/formatters/html.py +750 -0
  67. data/vendor/pygments-main/pygments/formatters/img.py +553 -0
  68. data/vendor/pygments-main/pygments/formatters/latex.py +378 -0
  69. data/vendor/pygments-main/pygments/formatters/other.py +117 -0
  70. data/vendor/pygments-main/pygments/formatters/rtf.py +136 -0
  71. data/vendor/pygments-main/pygments/formatters/svg.py +154 -0
  72. data/vendor/pygments-main/pygments/formatters/terminal.py +112 -0
  73. data/vendor/pygments-main/pygments/formatters/terminal256.py +222 -0
  74. data/vendor/pygments-main/pygments/lexer.py +697 -0
  75. data/vendor/pygments-main/pygments/lexers/__init__.py +229 -0
  76. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1645 -0
  77. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +232 -0
  78. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +249 -0
  79. data/vendor/pygments-main/pygments/lexers/_mapping.py +298 -0
  80. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
  81. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +232 -0
  82. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +29 -0
  83. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +3 -0
  84. data/vendor/pygments-main/pygments/lexers/agile.py +1803 -0
  85. data/vendor/pygments-main/pygments/lexers/asm.py +360 -0
  86. data/vendor/pygments-main/pygments/lexers/compiled.py +2891 -0
  87. data/vendor/pygments-main/pygments/lexers/dotnet.py +636 -0
  88. data/vendor/pygments-main/pygments/lexers/functional.py +1832 -0
  89. data/vendor/pygments-main/pygments/lexers/github.py +362 -0
  90. data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
  91. data/vendor/pygments-main/pygments/lexers/jvm.py +847 -0
  92. data/vendor/pygments-main/pygments/lexers/math.py +1072 -0
  93. data/vendor/pygments-main/pygments/lexers/other.py +3339 -0
  94. data/vendor/pygments-main/pygments/lexers/parsers.py +695 -0
  95. data/vendor/pygments-main/pygments/lexers/shell.py +361 -0
  96. data/vendor/pygments-main/pygments/lexers/special.py +100 -0
  97. data/vendor/pygments-main/pygments/lexers/sql.py +559 -0
  98. data/vendor/pygments-main/pygments/lexers/templates.py +1631 -0
  99. data/vendor/pygments-main/pygments/lexers/text.py +1753 -0
  100. data/vendor/pygments-main/pygments/lexers/web.py +2864 -0
  101. data/vendor/pygments-main/pygments/plugin.py +74 -0
  102. data/vendor/pygments-main/pygments/scanner.py +104 -0
  103. data/vendor/pygments-main/pygments/style.py +117 -0
  104. data/vendor/pygments-main/pygments/styles/__init__.py +70 -0
  105. data/vendor/pygments-main/pygments/styles/autumn.py +65 -0
  106. data/vendor/pygments-main/pygments/styles/borland.py +51 -0
  107. data/vendor/pygments-main/pygments/styles/bw.py +49 -0
  108. data/vendor/pygments-main/pygments/styles/colorful.py +81 -0
  109. data/vendor/pygments-main/pygments/styles/default.py +73 -0
  110. data/vendor/pygments-main/pygments/styles/emacs.py +72 -0
  111. data/vendor/pygments-main/pygments/styles/friendly.py +72 -0
  112. data/vendor/pygments-main/pygments/styles/fruity.py +42 -0
  113. data/vendor/pygments-main/pygments/styles/manni.py +75 -0
  114. data/vendor/pygments-main/pygments/styles/monokai.py +106 -0
  115. data/vendor/pygments-main/pygments/styles/murphy.py +80 -0
  116. data/vendor/pygments-main/pygments/styles/native.py +65 -0
  117. data/vendor/pygments-main/pygments/styles/pastie.py +75 -0
  118. data/vendor/pygments-main/pygments/styles/perldoc.py +69 -0
  119. data/vendor/pygments-main/pygments/styles/rrt.py +33 -0
  120. data/vendor/pygments-main/pygments/styles/tango.py +141 -0
  121. data/vendor/pygments-main/pygments/styles/trac.py +63 -0
  122. data/vendor/pygments-main/pygments/styles/vim.py +63 -0
  123. data/vendor/pygments-main/pygments/styles/vs.py +38 -0
  124. data/vendor/pygments-main/pygments/token.py +195 -0
  125. data/vendor/pygments-main/pygments/unistring.py +130 -0
  126. data/vendor/pygments-main/pygments/util.py +232 -0
  127. data/vendor/pygments-main/scripts/check_sources.py +242 -0
  128. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +30 -0
  129. data/vendor/pygments-main/scripts/epydoc.css +280 -0
  130. data/vendor/pygments-main/scripts/find_codetags.py +205 -0
  131. data/vendor/pygments-main/scripts/find_error.py +171 -0
  132. data/vendor/pygments-main/scripts/get_vimkw.py +43 -0
  133. data/vendor/pygments-main/scripts/pylintrc +301 -0
  134. data/vendor/pygments-main/scripts/reindent.py +291 -0
  135. data/vendor/pygments-main/scripts/vim2pygments.py +933 -0
  136. data/vendor/pygments-main/setup.cfg +6 -0
  137. data/vendor/pygments-main/setup.py +88 -0
  138. data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +37 -0
  139. data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +869 -0
  140. data/vendor/pygments-main/tests/dtds/HTML4.dcl +88 -0
  141. data/vendor/pygments-main/tests/dtds/HTML4.dtd +1092 -0
  142. data/vendor/pygments-main/tests/dtds/HTML4.soc +9 -0
  143. data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +195 -0
  144. data/vendor/pygments-main/tests/dtds/HTMLspec.ent +77 -0
  145. data/vendor/pygments-main/tests/dtds/HTMLsym.ent +241 -0
  146. data/vendor/pygments-main/tests/examplefiles/ANTLRv3.g +608 -0
  147. data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +209 -0
  148. data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +102 -0
  149. data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +611 -0
  150. data/vendor/pygments-main/tests/examplefiles/Constants.mo +158 -0
  151. data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +411 -0
  152. data/vendor/pygments-main/tests/examplefiles/Errors.scala +18 -0
  153. data/vendor/pygments-main/tests/examplefiles/File.hy +174 -0
  154. data/vendor/pygments-main/tests/examplefiles/Intro.java +1660 -0
  155. data/vendor/pygments-main/tests/examplefiles/Makefile +1131 -0
  156. data/vendor/pygments-main/tests/examplefiles/Object.st +4394 -0
  157. data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +584 -0
  158. data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +378 -0
  159. data/vendor/pygments-main/tests/examplefiles/Sorting.mod +470 -0
  160. data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +382 -0
  161. data/vendor/pygments-main/tests/examplefiles/addressbook.proto +30 -0
  162. data/vendor/pygments-main/tests/examplefiles/antlr_throws +1 -0
  163. data/vendor/pygments-main/tests/examplefiles/apache2.conf +393 -0
  164. data/vendor/pygments-main/tests/examplefiles/as3_test.as +143 -0
  165. data/vendor/pygments-main/tests/examplefiles/as3_test2.as +46 -0
  166. data/vendor/pygments-main/tests/examplefiles/as3_test3.as +3 -0
  167. data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +27 -0
  168. data/vendor/pygments-main/tests/examplefiles/badcase.java +2 -0
  169. data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
  170. data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -0
  171. data/vendor/pygments-main/tests/examplefiles/cells.ps +515 -0
  172. data/vendor/pygments-main/tests/examplefiles/ceval.c +2604 -0
  173. data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +13 -0
  174. data/vendor/pygments-main/tests/examplefiles/classes.dylan +40 -0
  175. data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +10 -0
  176. data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +447 -0
  177. data/vendor/pygments-main/tests/examplefiles/database.pytb +20 -0
  178. data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +2461 -0
  179. data/vendor/pygments-main/tests/examplefiles/demo.ahk +181 -0
  180. data/vendor/pygments-main/tests/examplefiles/demo.cfm +38 -0
  181. data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +68 -0
  182. data/vendor/pygments-main/tests/examplefiles/dwarf.cw +17 -0
  183. data/vendor/pygments-main/tests/examplefiles/erl_session +10 -0
  184. data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +1 -0
  185. data/vendor/pygments-main/tests/examplefiles/evil_regex.js +48 -0
  186. data/vendor/pygments-main/tests/examplefiles/example.c +2080 -0
  187. data/vendor/pygments-main/tests/examplefiles/example.cls +15 -0
  188. data/vendor/pygments-main/tests/examplefiles/example.cpp +2363 -0
  189. data/vendor/pygments-main/tests/examplefiles/example.gs +106 -0
  190. data/vendor/pygments-main/tests/examplefiles/example.gst +7 -0
  191. data/vendor/pygments-main/tests/examplefiles/example.kt +47 -0
  192. data/vendor/pygments-main/tests/examplefiles/example.lua +250 -0
  193. data/vendor/pygments-main/tests/examplefiles/example.moo +26 -0
  194. data/vendor/pygments-main/tests/examplefiles/example.moon +629 -0
  195. data/vendor/pygments-main/tests/examplefiles/example.nim +1010 -0
  196. data/vendor/pygments-main/tests/examplefiles/example.ns2 +69 -0
  197. data/vendor/pygments-main/tests/examplefiles/example.p +34 -0
  198. data/vendor/pygments-main/tests/examplefiles/example.pas +2708 -0
  199. data/vendor/pygments-main/tests/examplefiles/example.rb +1852 -0
  200. data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
  201. data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -0
  202. data/vendor/pygments-main/tests/examplefiles/example.sml +156 -0
  203. data/vendor/pygments-main/tests/examplefiles/example.snobol +15 -0
  204. data/vendor/pygments-main/tests/examplefiles/example.tea +34 -0
  205. data/vendor/pygments-main/tests/examplefiles/example.u +548 -0
  206. data/vendor/pygments-main/tests/examplefiles/example.weechatlog +9 -0
  207. data/vendor/pygments-main/tests/examplefiles/example.xhtml +376 -0
  208. data/vendor/pygments-main/tests/examplefiles/example.yaml +302 -0
  209. data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -0
  210. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +363 -0
  211. data/vendor/pygments-main/tests/examplefiles/example_file.fy +128 -0
  212. data/vendor/pygments-main/tests/examplefiles/firefox.mak +586 -0
  213. data/vendor/pygments-main/tests/examplefiles/flipflop.sv +19 -0
  214. data/vendor/pygments-main/tests/examplefiles/foo.sce +6 -0
  215. data/vendor/pygments-main/tests/examplefiles/format.ml +1213 -0
  216. data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +77 -0
  217. data/vendor/pygments-main/tests/examplefiles/function.mu +1 -0
  218. data/vendor/pygments-main/tests/examplefiles/functional.rst +1472 -0
  219. data/vendor/pygments-main/tests/examplefiles/genclass.clj +510 -0
  220. data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +193 -0
  221. data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +33 -0
  222. data/vendor/pygments-main/tests/examplefiles/glsl.frag +7 -0
  223. data/vendor/pygments-main/tests/examplefiles/glsl.vert +13 -0
  224. data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +1 -0
  225. data/vendor/pygments-main/tests/examplefiles/http_request_example +14 -0
  226. data/vendor/pygments-main/tests/examplefiles/http_response_example +27 -0
  227. data/vendor/pygments-main/tests/examplefiles/import.hs +4 -0
  228. data/vendor/pygments-main/tests/examplefiles/intro.ik +24 -0
  229. data/vendor/pygments-main/tests/examplefiles/ints.php +10 -0
  230. data/vendor/pygments-main/tests/examplefiles/intsyn.fun +675 -0
  231. data/vendor/pygments-main/tests/examplefiles/intsyn.sig +286 -0
  232. data/vendor/pygments-main/tests/examplefiles/irb_heredoc +8 -0
  233. data/vendor/pygments-main/tests/examplefiles/irc.lsp +214 -0
  234. data/vendor/pygments-main/tests/examplefiles/java.properties +16 -0
  235. data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +28 -0
  236. data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +45 -0
  237. data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +713 -0
  238. data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +13 -0
  239. data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -0
  240. data/vendor/pygments-main/tests/examplefiles/ltmain.sh +2849 -0
  241. data/vendor/pygments-main/tests/examplefiles/main.cmake +42 -0
  242. data/vendor/pygments-main/tests/examplefiles/markdown.lsp +679 -0
  243. data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +3 -0
  244. data/vendor/pygments-main/tests/examplefiles/matlab_sample +27 -0
  245. data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -0
  246. data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +4 -0
  247. data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +340 -0
  248. data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +38 -0
  249. data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +96 -0
  250. data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +30 -0
  251. data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +87 -0
  252. data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +118 -0
  253. data/vendor/pygments-main/tests/examplefiles/numbers.c +12 -0
  254. data/vendor/pygments-main/tests/examplefiles/objc_example.m +25 -0
  255. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +24 -0
  256. data/vendor/pygments-main/tests/examplefiles/perl_misc +62 -0
  257. data/vendor/pygments-main/tests/examplefiles/perl_perl5db +998 -0
  258. data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +120 -0
  259. data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +856 -0
  260. data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +567 -0
  261. data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +1223 -0
  262. data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +47 -0
  263. data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +10 -0
  264. data/vendor/pygments-main/tests/examplefiles/psql_session.txt +122 -0
  265. data/vendor/pygments-main/tests/examplefiles/py3_test.txt +2 -0
  266. data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +14 -0
  267. data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -0
  268. data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +234 -0
  269. data/vendor/pygments-main/tests/examplefiles/qsort.prolog +13 -0
  270. data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +38 -0
  271. data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +280 -0
  272. data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +2 -0
  273. data/vendor/pygments-main/tests/examplefiles/regex.js +22 -0
  274. data/vendor/pygments-main/tests/examplefiles/reversi.lsp +427 -0
  275. data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +11 -0
  276. data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -0
  277. data/vendor/pygments-main/tests/examplefiles/sibling.prolog +19 -0
  278. data/vendor/pygments-main/tests/examplefiles/simple.md +747 -0
  279. data/vendor/pygments-main/tests/examplefiles/smarty_example.html +209 -0
  280. data/vendor/pygments-main/tests/examplefiles/source.lgt +343 -0
  281. data/vendor/pygments-main/tests/examplefiles/sources.list +62 -0
  282. data/vendor/pygments-main/tests/examplefiles/sphere.pov +18 -0
  283. data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +27 -0
  284. data/vendor/pygments-main/tests/examplefiles/squid.conf +30 -0
  285. data/vendor/pygments-main/tests/examplefiles/string.jl +1031 -0
  286. data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +21 -0
  287. data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +3 -0
  288. data/vendor/pygments-main/tests/examplefiles/test.R +119 -0
  289. data/vendor/pygments-main/tests/examplefiles/test.adb +211 -0
  290. data/vendor/pygments-main/tests/examplefiles/test.asy +131 -0
  291. data/vendor/pygments-main/tests/examplefiles/test.awk +121 -0
  292. data/vendor/pygments-main/tests/examplefiles/test.bas +29 -0
  293. data/vendor/pygments-main/tests/examplefiles/test.bmx +145 -0
  294. data/vendor/pygments-main/tests/examplefiles/test.boo +39 -0
  295. data/vendor/pygments-main/tests/examplefiles/test.bro +250 -0
  296. data/vendor/pygments-main/tests/examplefiles/test.cs +374 -0
  297. data/vendor/pygments-main/tests/examplefiles/test.css +54 -0
  298. data/vendor/pygments-main/tests/examplefiles/test.d +135 -0
  299. data/vendor/pygments-main/tests/examplefiles/test.dart +23 -0
  300. data/vendor/pygments-main/tests/examplefiles/test.dtd +89 -0
  301. data/vendor/pygments-main/tests/examplefiles/test.ec +605 -0
  302. data/vendor/pygments-main/tests/examplefiles/test.ecl +58 -0
  303. data/vendor/pygments-main/tests/examplefiles/test.eh +315 -0
  304. data/vendor/pygments-main/tests/examplefiles/test.erl +169 -0
  305. data/vendor/pygments-main/tests/examplefiles/test.evoque +33 -0
  306. data/vendor/pygments-main/tests/examplefiles/test.fan +818 -0
  307. data/vendor/pygments-main/tests/examplefiles/test.flx +57 -0
  308. data/vendor/pygments-main/tests/examplefiles/test.gdc +13 -0
  309. data/vendor/pygments-main/tests/examplefiles/test.groovy +97 -0
  310. data/vendor/pygments-main/tests/examplefiles/test.html +339 -0
  311. data/vendor/pygments-main/tests/examplefiles/test.ini +10 -0
  312. data/vendor/pygments-main/tests/examplefiles/test.java +653 -0
  313. data/vendor/pygments-main/tests/examplefiles/test.jsp +24 -0
  314. data/vendor/pygments-main/tests/examplefiles/test.maql +45 -0
  315. data/vendor/pygments-main/tests/examplefiles/test.mod +374 -0
  316. data/vendor/pygments-main/tests/examplefiles/test.moo +51 -0
  317. data/vendor/pygments-main/tests/examplefiles/test.myt +166 -0
  318. data/vendor/pygments-main/tests/examplefiles/test.nim +93 -0
  319. data/vendor/pygments-main/tests/examplefiles/test.pas +743 -0
  320. data/vendor/pygments-main/tests/examplefiles/test.php +505 -0
  321. data/vendor/pygments-main/tests/examplefiles/test.plot +333 -0
  322. data/vendor/pygments-main/tests/examplefiles/test.ps1 +108 -0
  323. data/vendor/pygments-main/tests/examplefiles/test.pypylog +1839 -0
  324. data/vendor/pygments-main/tests/examplefiles/test.r3 +94 -0
  325. data/vendor/pygments-main/tests/examplefiles/test.rb +177 -0
  326. data/vendor/pygments-main/tests/examplefiles/test.rhtml +43 -0
  327. data/vendor/pygments-main/tests/examplefiles/test.scaml +8 -0
  328. data/vendor/pygments-main/tests/examplefiles/test.ssp +12 -0
  329. data/vendor/pygments-main/tests/examplefiles/test.tcsh +830 -0
  330. data/vendor/pygments-main/tests/examplefiles/test.vb +407 -0
  331. data/vendor/pygments-main/tests/examplefiles/test.vhdl +161 -0
  332. data/vendor/pygments-main/tests/examplefiles/test.xqy +138 -0
  333. data/vendor/pygments-main/tests/examplefiles/test.xsl +23 -0
  334. data/vendor/pygments-main/tests/examplefiles/truncated.pytb +15 -0
  335. data/vendor/pygments-main/tests/examplefiles/type.lisp +1202 -0
  336. data/vendor/pygments-main/tests/examplefiles/underscore.coffee +603 -0
  337. data/vendor/pygments-main/tests/examplefiles/unicode.applescript +5 -0
  338. data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +11 -0
  339. data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +3 -0
  340. data/vendor/pygments-main/tests/examplefiles/while.pov +13 -0
  341. data/vendor/pygments-main/tests/examplefiles/wiki.factor +384 -0
  342. data/vendor/pygments-main/tests/examplefiles/xml_example +1897 -0
  343. data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +798 -0
  344. data/vendor/pygments-main/tests/old_run.py +138 -0
  345. data/vendor/pygments-main/tests/run.py +48 -0
  346. data/vendor/pygments-main/tests/support.py +15 -0
  347. data/vendor/pygments-main/tests/test_basic_api.py +294 -0
  348. data/vendor/pygments-main/tests/test_clexer.py +31 -0
  349. data/vendor/pygments-main/tests/test_cmdline.py +105 -0
  350. data/vendor/pygments-main/tests/test_examplefiles.py +97 -0
  351. data/vendor/pygments-main/tests/test_html_formatter.py +162 -0
  352. data/vendor/pygments-main/tests/test_latex_formatter.py +55 -0
  353. data/vendor/pygments-main/tests/test_perllexer.py +137 -0
  354. data/vendor/pygments-main/tests/test_regexlexer.py +47 -0
  355. data/vendor/pygments-main/tests/test_token.py +46 -0
  356. data/vendor/pygments-main/tests/test_using_api.py +40 -0
  357. data/vendor/pygments-main/tests/test_util.py +116 -0
  358. data/vendor/simplejson/.gitignore +10 -0
  359. data/vendor/simplejson/.travis.yml +5 -0
  360. data/vendor/simplejson/CHANGES.txt +291 -0
  361. data/vendor/simplejson/LICENSE.txt +19 -0
  362. data/vendor/simplejson/MANIFEST.in +5 -0
  363. data/vendor/simplejson/README.rst +19 -0
  364. data/vendor/simplejson/conf.py +179 -0
  365. data/vendor/simplejson/index.rst +628 -0
  366. data/vendor/simplejson/scripts/make_docs.py +18 -0
  367. data/vendor/simplejson/setup.py +104 -0
  368. data/vendor/simplejson/simplejson/__init__.py +510 -0
  369. data/vendor/simplejson/simplejson/_speedups.c +2745 -0
  370. data/vendor/simplejson/simplejson/decoder.py +425 -0
  371. data/vendor/simplejson/simplejson/encoder.py +567 -0
  372. data/vendor/simplejson/simplejson/ordered_dict.py +119 -0
  373. data/vendor/simplejson/simplejson/scanner.py +77 -0
  374. data/vendor/simplejson/simplejson/tests/__init__.py +67 -0
  375. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +55 -0
  376. data/vendor/simplejson/simplejson/tests/test_check_circular.py +30 -0
  377. data/vendor/simplejson/simplejson/tests/test_decimal.py +66 -0
  378. data/vendor/simplejson/simplejson/tests/test_decode.py +83 -0
  379. data/vendor/simplejson/simplejson/tests/test_default.py +9 -0
  380. data/vendor/simplejson/simplejson/tests/test_dump.py +67 -0
  381. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +46 -0
  382. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +32 -0
  383. data/vendor/simplejson/simplejson/tests/test_errors.py +34 -0
  384. data/vendor/simplejson/simplejson/tests/test_fail.py +91 -0
  385. data/vendor/simplejson/simplejson/tests/test_float.py +19 -0
  386. data/vendor/simplejson/simplejson/tests/test_indent.py +86 -0
  387. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +20 -0
  388. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +121 -0
  389. data/vendor/simplejson/simplejson/tests/test_pass1.py +76 -0
  390. data/vendor/simplejson/simplejson/tests/test_pass2.py +14 -0
  391. data/vendor/simplejson/simplejson/tests/test_pass3.py +20 -0
  392. data/vendor/simplejson/simplejson/tests/test_recursion.py +67 -0
  393. data/vendor/simplejson/simplejson/tests/test_scanstring.py +117 -0
  394. data/vendor/simplejson/simplejson/tests/test_separators.py +42 -0
  395. data/vendor/simplejson/simplejson/tests/test_speedups.py +20 -0
  396. data/vendor/simplejson/simplejson/tests/test_tuple.py +49 -0
  397. data/vendor/simplejson/simplejson/tests/test_unicode.py +109 -0
  398. data/vendor/simplejson/simplejson/tool.py +39 -0
  399. metadata +492 -0
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2006 Bob Ippolito
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include *.py
2
+ include *.txt
3
+ include *.rst
4
+ include scripts/*.py
5
+ include MANIFEST.in
@@ -0,0 +1,19 @@
1
+ simplejson is a simple, fast, complete, correct and extensible
2
+ JSON <http://json.org> encoder and decoder for Python 2.5+. It is
3
+ pure Python code with no dependencies, but includes an optional C
4
+ extension for a serious speed boost.
5
+
6
+ The latest documentation for simplejson can be read online here:
7
+ http://simplejson.readthedocs.org/
8
+
9
+ simplejson is the externally maintained development version of the
10
+ json library included with Python 2.6 and Python 3.0, but maintains
11
+ backwards compatibility with Python 2.5.
12
+
13
+ The encoder may be subclassed to provide serialization in any kind of
14
+ situation, without any special support by the objects to be serialized
15
+ (somewhat like pickle).
16
+
17
+ The decoder can handle incoming JSON strings of any specified encoding
18
+ (UTF-8 by default).
19
+
@@ -0,0 +1,179 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # simplejson documentation build configuration file, created by
4
+ # sphinx-quickstart on Fri Sep 26 18:58:30 2008.
5
+ #
6
+ # This file is execfile()d with the current directory set to its containing dir.
7
+ #
8
+ # The contents of this file are pickled, so don't put values in the namespace
9
+ # that aren't pickleable (module imports are okay, they're removed automatically).
10
+ #
11
+ # All configuration values have a default value; values that are commented out
12
+ # serve to show the default value.
13
+
14
+ import sys, os
15
+
16
+ # If your extensions are in another directory, add it here. If the directory
17
+ # is relative to the documentation root, use os.path.abspath to make it
18
+ # absolute, like shown here.
19
+ #sys.path.append(os.path.abspath('some/directory'))
20
+
21
+ # General configuration
22
+ # ---------------------
23
+
24
+ # Add any Sphinx extension module names here, as strings. They can be extensions
25
+ # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
26
+ extensions = []
27
+
28
+ # Add any paths that contain templates here, relative to this directory.
29
+ templates_path = ['_templates']
30
+
31
+ # The suffix of source filenames.
32
+ source_suffix = '.rst'
33
+
34
+ # The master toctree document.
35
+ master_doc = 'index'
36
+
37
+ # General substitutions.
38
+ project = 'simplejson'
39
+ copyright = '2012, Bob Ippolito'
40
+
41
+ # The default replacements for |version| and |release|, also used in various
42
+ # other places throughout the built documents.
43
+ #
44
+ # The short X.Y version.
45
+ version = '2.6'
46
+ # The full version, including alpha/beta/rc tags.
47
+ release = '2.6.0'
48
+
49
+ # There are two options for replacing |today|: either, you set today to some
50
+ # non-false value, then it is used:
51
+ #today = ''
52
+ # Else, today_fmt is used as the format for a strftime call.
53
+ today_fmt = '%B %d, %Y'
54
+
55
+ # List of documents that shouldn't be included in the build.
56
+ #unused_docs = []
57
+
58
+ # List of directories, relative to source directories, that shouldn't be searched
59
+ # for source files.
60
+ #exclude_dirs = []
61
+
62
+ # The reST default role (used for this markup: `text`) to use for all documents.
63
+ #default_role = None
64
+
65
+ # If true, '()' will be appended to :func: etc. cross-reference text.
66
+ #add_function_parentheses = True
67
+
68
+ # If true, the current module name will be prepended to all description
69
+ # unit titles (such as .. function::).
70
+ #add_module_names = True
71
+
72
+ # If true, sectionauthor and moduleauthor directives will be shown in the
73
+ # output. They are ignored by default.
74
+ #show_authors = False
75
+
76
+ # The name of the Pygments (syntax highlighting) style to use.
77
+ pygments_style = 'sphinx'
78
+
79
+
80
+ # Options for HTML output
81
+ # -----------------------
82
+
83
+ # The style sheet to use for HTML and HTML Help pages. A file of that name
84
+ # must exist either in Sphinx' static/ path, or in one of the custom paths
85
+ # given in html_static_path.
86
+ html_style = 'default.css'
87
+
88
+ # The name for this set of Sphinx documents. If None, it defaults to
89
+ # "<project> v<release> documentation".
90
+ #html_title = None
91
+
92
+ # A shorter title for the navigation bar. Default is the same as html_title.
93
+ #html_short_title = None
94
+
95
+ # The name of an image file (within the static path) to place at the top of
96
+ # the sidebar.
97
+ #html_logo = None
98
+
99
+ # The name of an image file (within the static path) to use as favicon of the
100
+ # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
101
+ # pixels large.
102
+ #html_favicon = None
103
+
104
+ # Add any paths that contain custom static files (such as style sheets) here,
105
+ # relative to this directory. They are copied after the builtin static files,
106
+ # so a file named "default.css" will overwrite the builtin "default.css".
107
+ html_static_path = ['_static']
108
+
109
+ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
110
+ # using the given strftime format.
111
+ html_last_updated_fmt = '%b %d, %Y'
112
+
113
+ # If true, SmartyPants will be used to convert quotes and dashes to
114
+ # typographically correct entities.
115
+ #html_use_smartypants = True
116
+
117
+ # Custom sidebar templates, maps document names to template names.
118
+ #html_sidebars = {}
119
+
120
+ # Additional templates that should be rendered to pages, maps page names to
121
+ # template names.
122
+ #html_additional_pages = {}
123
+
124
+ # If false, no module index is generated.
125
+ html_use_modindex = False
126
+
127
+ # If false, no index is generated.
128
+ #html_use_index = True
129
+
130
+ # If true, the index is split into individual pages for each letter.
131
+ #html_split_index = False
132
+
133
+ # If true, the reST sources are included in the HTML build as _sources/<name>.
134
+ #html_copy_source = True
135
+
136
+ # If true, an OpenSearch description file will be output, and all pages will
137
+ # contain a <link> tag referring to it. The value of this option must be the
138
+ # base URL from which the finished HTML is served.
139
+ #html_use_opensearch = ''
140
+
141
+ # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
142
+ html_file_suffix = '.html'
143
+
144
+ # Output file base name for HTML help builder.
145
+ htmlhelp_basename = 'simplejsondoc'
146
+
147
+
148
+ # Options for LaTeX output
149
+ # ------------------------
150
+
151
+ # The paper size ('letter' or 'a4').
152
+ #latex_paper_size = 'letter'
153
+
154
+ # The font size ('10pt', '11pt' or '12pt').
155
+ #latex_font_size = '10pt'
156
+
157
+ # Grouping the document tree into LaTeX files. List of tuples
158
+ # (source start file, target name, title, author, document class [howto/manual]).
159
+ latex_documents = [
160
+ ('index', 'simplejson.tex', 'simplejson Documentation',
161
+ 'Bob Ippolito', 'manual'),
162
+ ]
163
+
164
+ # The name of an image file (relative to this directory) to place at the top of
165
+ # the title page.
166
+ #latex_logo = None
167
+
168
+ # For "manual" documents, if this is true, then toplevel headings are parts,
169
+ # not chapters.
170
+ #latex_use_parts = False
171
+
172
+ # Additional stuff for the LaTeX preamble.
173
+ #latex_preamble = ''
174
+
175
+ # Documents to append as an appendix to all manuals.
176
+ #latex_appendices = []
177
+
178
+ # If false, no module index is generated.
179
+ #latex_use_modindex = True
@@ -0,0 +1,628 @@
1
+ :mod:`simplejson` --- JSON encoder and decoder
2
+ ==============================================
3
+
4
+ .. module:: simplejson
5
+ :synopsis: Encode and decode the JSON format.
6
+ .. moduleauthor:: Bob Ippolito <bob@redivi.com>
7
+ .. sectionauthor:: Bob Ippolito <bob@redivi.com>
8
+
9
+ JSON (JavaScript Object Notation) <http://json.org> is a subset of JavaScript
10
+ syntax (ECMA-262 3rd edition) used as a lightweight data interchange format.
11
+
12
+ :mod:`simplejson` exposes an API familiar to users of the standard library
13
+ :mod:`marshal` and :mod:`pickle` modules. It is the externally maintained
14
+ version of the :mod:`json` library contained in Python 2.6, but maintains
15
+ compatibility with Python 2.5 and (currently) has
16
+ significant performance advantages, even without using the optional C
17
+ extension for speedups.
18
+
19
+ Development of simplejson happens on Github:
20
+ http://github.com/simplejson/simplejson
21
+
22
+ Encoding basic Python object hierarchies::
23
+
24
+ >>> import simplejson as json
25
+ >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
26
+ '["foo", {"bar": ["baz", null, 1.0, 2]}]'
27
+ >>> print json.dumps("\"foo\bar")
28
+ "\"foo\bar"
29
+ >>> print json.dumps(u'\u1234')
30
+ "\u1234"
31
+ >>> print json.dumps('\\')
32
+ "\\"
33
+ >>> print json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
34
+ {"a": 0, "b": 0, "c": 0}
35
+ >>> from StringIO import StringIO
36
+ >>> io = StringIO()
37
+ >>> json.dump(['streaming API'], io)
38
+ >>> io.getvalue()
39
+ '["streaming API"]'
40
+
41
+ Compact encoding::
42
+
43
+ >>> import simplejson as json
44
+ >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
45
+ '[1,2,3,{"4":5,"6":7}]'
46
+
47
+ Pretty printing::
48
+
49
+ >>> import simplejson as json
50
+ >>> s = json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4 * ' ')
51
+ >>> print '\n'.join([l.rstrip() for l in s.splitlines()])
52
+ {
53
+ "4": 5,
54
+ "6": 7
55
+ }
56
+
57
+ Decoding JSON::
58
+
59
+ >>> import simplejson as json
60
+ >>> obj = [u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
61
+ >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') == obj
62
+ True
63
+ >>> json.loads('"\\"foo\\bar"') == u'"foo\x08ar'
64
+ True
65
+ >>> from StringIO import StringIO
66
+ >>> io = StringIO('["streaming API"]')
67
+ >>> json.load(io)[0] == 'streaming API'
68
+ True
69
+
70
+ Using Decimal instead of float::
71
+
72
+ >>> import simplejson as json
73
+ >>> from decimal import Decimal
74
+ >>> json.loads('1.1', use_decimal=True) == Decimal('1.1')
75
+ True
76
+ >>> json.dumps(Decimal('1.1'), use_decimal=True) == '1.1'
77
+ True
78
+
79
+ Specializing JSON object decoding::
80
+
81
+ >>> import simplejson as json
82
+ >>> def as_complex(dct):
83
+ ... if '__complex__' in dct:
84
+ ... return complex(dct['real'], dct['imag'])
85
+ ... return dct
86
+ ...
87
+ >>> json.loads('{"__complex__": true, "real": 1, "imag": 2}',
88
+ ... object_hook=as_complex)
89
+ (1+2j)
90
+ >>> import decimal
91
+ >>> json.loads('1.1', parse_float=decimal.Decimal) == decimal.Decimal('1.1')
92
+ True
93
+
94
+ Specializing JSON object encoding::
95
+
96
+ >>> import simplejson as json
97
+ >>> def encode_complex(obj):
98
+ ... if isinstance(obj, complex):
99
+ ... return [obj.real, obj.imag]
100
+ ... raise TypeError(repr(o) + " is not JSON serializable")
101
+ ...
102
+ >>> json.dumps(2 + 1j, default=encode_complex)
103
+ '[2.0, 1.0]'
104
+ >>> json.JSONEncoder(default=encode_complex).encode(2 + 1j)
105
+ '[2.0, 1.0]'
106
+ >>> ''.join(json.JSONEncoder(default=encode_complex).iterencode(2 + 1j))
107
+ '[2.0, 1.0]'
108
+
109
+
110
+ .. highlight:: none
111
+
112
+ Using :mod:`simplejson.tool` from the shell to validate and pretty-print::
113
+
114
+ $ echo '{"json":"obj"}' | python -m simplejson.tool
115
+ {
116
+ "json": "obj"
117
+ }
118
+ $ echo '{ 1.2:3.4}' | python -m simplejson.tool
119
+ Expecting property name enclosed in double quotes: line 1 column 2 (char 2)
120
+
121
+ .. highlight:: python
122
+
123
+ .. note::
124
+
125
+ The JSON produced by this module's default settings is a subset of
126
+ YAML, so it may be used as a serializer for that as well.
127
+
128
+
129
+ Basic Usage
130
+ -----------
131
+
132
+ .. function:: dump(obj, fp[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, bigint_as_string[, sort_keys[, item_sort_key[, **kw]]]]]]]]]]]]]]]])
133
+
134
+ Serialize *obj* as a JSON formatted stream to *fp* (a ``.write()``-supporting
135
+ file-like object).
136
+
137
+ If *skipkeys* is true (default: ``False``), then dict keys that are not
138
+ of a basic type (:class:`str`, :class:`unicode`, :class:`int`, :class:`long`,
139
+ :class:`float`, :class:`bool`, ``None``) will be skipped instead of raising a
140
+ :exc:`TypeError`.
141
+
142
+ If *ensure_ascii* is false (default: ``True``), then some chunks written
143
+ to *fp* may be :class:`unicode` instances, subject to normal Python
144
+ :class:`str` to :class:`unicode` coercion rules. Unless ``fp.write()``
145
+ explicitly understands :class:`unicode` (as in :func:`codecs.getwriter`) this
146
+ is likely to cause an error. It's best to leave the default settings, because
147
+ they are safe and it is highly optimized.
148
+
149
+ If *check_circular* is false (default: ``True``), then the circular
150
+ reference check for container types will be skipped and a circular reference
151
+ will result in an :exc:`OverflowError` (or worse).
152
+
153
+ If *allow_nan* is false (default: ``True``), then it will be a
154
+ :exc:`ValueError` to serialize out of range :class:`float` values (``nan``,
155
+ ``inf``, ``-inf``) in strict compliance of the JSON specification.
156
+ If *allow_nan* is true, their JavaScript equivalents will be used
157
+ (``NaN``, ``Infinity``, ``-Infinity``).
158
+
159
+ If *indent* is a string, then JSON array elements and object members
160
+ will be pretty-printed with a newline followed by that string repeated
161
+ for each level of nesting. ``None`` (the default) selects the most compact
162
+ representation without any newlines. For backwards compatibility with
163
+ versions of simplejson earlier than 2.1.0, an integer is also accepted
164
+ and is converted to a string with that many spaces.
165
+
166
+ .. versionchanged:: 2.1.0
167
+ Changed *indent* from an integer number of spaces to a string.
168
+
169
+ If specified, *separators* should be an ``(item_separator, dict_separator)``
170
+ tuple. By default, ``(', ', ': ')`` are used. To get the most compact JSON
171
+ representation, you should specify ``(',', ':')`` to eliminate whitespace.
172
+
173
+ *encoding* is the character encoding for str instances, default is
174
+ ``'utf-8'``.
175
+
176
+ *default(obj)* is a function that should return a serializable version of
177
+ *obj* or raise :exc:`TypeError`. The default simply raises :exc:`TypeError`.
178
+
179
+ To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the
180
+ :meth:`default` method to serialize additional types), specify it with the
181
+ *cls* kwarg.
182
+
183
+ If *use_decimal* is true (default: ``True``) then :class:`decimal.Decimal`
184
+ will be natively serialized to JSON with full precision.
185
+
186
+ .. versionchanged:: 2.1.0
187
+ *use_decimal* is new in 2.1.0.
188
+
189
+ .. versionchanged:: 2.2.0
190
+ The default of *use_decimal* changed to ``True`` in 2.2.0.
191
+
192
+ If *namedtuple_as_object* is true (default: ``True``),
193
+ objects with ``_asdict()`` methods will be encoded
194
+ as JSON objects.
195
+
196
+ .. versionchanged:: 2.2.0
197
+ *namedtuple_as_object* is new in 2.2.0.
198
+
199
+ .. versionchanged:: 2.3.0
200
+ *namedtuple_as_object* no longer requires that these objects be
201
+ subclasses of :class:`tuple`.
202
+
203
+ If *tuple_as_array* is true (default: ``True``),
204
+ :class:`tuple` (and subclasses) will be encoded as JSON arrays.
205
+
206
+ .. versionchanged:: 2.2.0
207
+ *tuple_as_array* is new in 2.2.0.
208
+
209
+ If *bigint_as_string* is true (default: ``False``), :class:`int`` ``2**53``
210
+ and higher or lower than ``-2**53`` will be encoded as strings. This is to
211
+ avoid the rounding that happens in Javascript otherwise. Note that this
212
+ option loses type information, so use with extreme caution.
213
+
214
+ .. versionchanged:: 2.4.0
215
+ *bigint_as_string* is new in 2.4.0.
216
+
217
+ If *sort_keys* is true (not the default), then the output of dictionaries
218
+ will be sorted by key; this is useful for regression tests to ensure that
219
+ JSON serializations can be compared on a day-to-day basis.
220
+
221
+ If *item_sort_key* is a callable (not the default), then the output of
222
+ dictionaries will be sorted with it. The callable will be used like this:
223
+ ``sorted(dct.items(), key=item_sort_key)``. This option takes precedence
224
+ over *sort_keys*.
225
+
226
+ .. versionchanged:: 2.5.0
227
+ *item_sort_key* is new in 2.5.0.
228
+
229
+ .. note::
230
+
231
+ JSON is not a framed protocol so unlike :mod:`pickle` or :mod:`marshal` it
232
+ does not make sense to serialize more than one JSON document without some
233
+ container protocol to delimit them.
234
+
235
+
236
+ .. function:: dumps(obj[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, bigint_as_string[, sort_keys[, item_sort_key[, **kw]]]]]]]]]]]]]]]])
237
+
238
+ Serialize *obj* to a JSON formatted :class:`str`.
239
+
240
+ If *ensure_ascii* is false, then the return value will be a
241
+ :class:`unicode` instance. The other arguments have the same meaning as in
242
+ :func:`dump`. Note that the default *ensure_ascii* setting has much
243
+ better performance.
244
+
245
+
246
+ .. function:: load(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, use_decimal[, **kw]]]]]]]]])
247
+
248
+ Deserialize *fp* (a ``.read()``-supporting file-like object containing a JSON
249
+ document) to a Python object. :exc:`JSONDecodeError` will be
250
+ raised if the given JSON document is not valid.
251
+
252
+ If the contents of *fp* are encoded with an ASCII based encoding other than
253
+ UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be specified.
254
+ Encodings that are not ASCII based (such as UCS-2) are not allowed, and
255
+ should be wrapped with ``codecs.getreader(fp)(encoding)``, or simply decoded
256
+ to a :class:`unicode` object and passed to :func:`loads`. The default
257
+ setting of ``'utf-8'`` is fastest and should be using whenever possible.
258
+
259
+ If *fp.read()* returns :class:`str` then decoded JSON strings that contain
260
+ only ASCII characters may be parsed as :class:`str` for performance and
261
+ memory reasons. If your code expects only :class:`unicode` the appropriate
262
+ solution is to wrap fp with a reader as demonstrated above.
263
+
264
+ *object_hook* is an optional function that will be called with the result of
265
+ any object literal decode (a :class:`dict`). The return value of
266
+ *object_hook* will be used instead of the :class:`dict`. This feature can be used
267
+ to implement custom decoders (e.g. JSON-RPC class hinting).
268
+
269
+ *object_pairs_hook* is an optional function that will be called with the
270
+ result of any object literal decode with an ordered list of pairs. The
271
+ return value of *object_pairs_hook* will be used instead of the
272
+ :class:`dict`. This feature can be used to implement custom decoders that
273
+ rely on the order that the key and value pairs are decoded (for example,
274
+ :class:`collections.OrderedDict` will remember the order of insertion). If
275
+ *object_hook* is also defined, the *object_pairs_hook* takes priority.
276
+
277
+ .. versionchanged:: 2.1.0
278
+ Added support for *object_pairs_hook*.
279
+
280
+ *parse_float*, if specified, will be called with the string of every JSON
281
+ float to be decoded. By default, this is equivalent to ``float(num_str)``.
282
+ This can be used to use another datatype or parser for JSON floats
283
+ (e.g. :class:`decimal.Decimal`).
284
+
285
+ *parse_int*, if specified, will be called with the string of every JSON int
286
+ to be decoded. By default, this is equivalent to ``int(num_str)``. This can
287
+ be used to use another datatype or parser for JSON integers
288
+ (e.g. :class:`float`).
289
+
290
+ *parse_constant*, if specified, will be called with one of the following
291
+ strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to
292
+ raise an exception if invalid JSON numbers are encountered.
293
+
294
+ If *use_decimal* is true (default: ``False``) then *parse_float* is set to
295
+ :class:`decimal.Decimal`. This is a convenience for parity with the
296
+ :func:`dump` parameter.
297
+
298
+ .. versionchanged:: 2.1.0
299
+ *use_decimal* is new in 2.1.0.
300
+
301
+ To use a custom :class:`JSONDecoder` subclass, specify it with the ``cls``
302
+ kwarg. Additional keyword arguments will be passed to the constructor of the
303
+ class.
304
+
305
+ .. note::
306
+
307
+ :func:`load` will read the rest of the file-like object as a string and
308
+ then call :func:`loads`. It does not stop at the end of the first valid
309
+ JSON document it finds and it will raise an error if there is anything
310
+ other than whitespace after the document. Except for files containing
311
+ only one JSON document, it is recommended to use :func:`loads`.
312
+
313
+
314
+ .. function:: loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, use_decimal[, **kw]]]]]]]]])
315
+
316
+ Deserialize *s* (a :class:`str` or :class:`unicode` instance containing a JSON
317
+ document) to a Python object. :exc:`JSONDecodeError` will be
318
+ raised if the given JSON document is not valid.
319
+
320
+ If *s* is a :class:`str` instance and is encoded with an ASCII based encoding
321
+ other than UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be
322
+ specified. Encodings that are not ASCII based (such as UCS-2) are not
323
+ allowed and should be decoded to :class:`unicode` first.
324
+
325
+ If *s* is a :class:`str` then decoded JSON strings that contain
326
+ only ASCII characters may be parsed as :class:`str` for performance and
327
+ memory reasons. If your code expects only :class:`unicode` the appropriate
328
+ solution is decode *s* to :class:`unicode` prior to calling loads.
329
+
330
+ The other arguments have the same meaning as in :func:`load`.
331
+
332
+
333
+ Encoders and decoders
334
+ ---------------------
335
+
336
+ .. class:: JSONDecoder([encoding[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, strict]]]]]]])
337
+
338
+ Simple JSON decoder.
339
+
340
+ Performs the following translations in decoding by default:
341
+
342
+ +---------------+-------------------+
343
+ | JSON | Python |
344
+ +===============+===================+
345
+ | object | dict |
346
+ +---------------+-------------------+
347
+ | array | list |
348
+ +---------------+-------------------+
349
+ | string | unicode |
350
+ +---------------+-------------------+
351
+ | number (int) | int, long |
352
+ +---------------+-------------------+
353
+ | number (real) | float |
354
+ +---------------+-------------------+
355
+ | true | True |
356
+ +---------------+-------------------+
357
+ | false | False |
358
+ +---------------+-------------------+
359
+ | null | None |
360
+ +---------------+-------------------+
361
+
362
+ It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as their
363
+ corresponding ``float`` values, which is outside the JSON spec.
364
+
365
+ *encoding* determines the encoding used to interpret any :class:`str` objects
366
+ decoded by this instance (``'utf-8'`` by default). It has no effect when decoding
367
+ :class:`unicode` objects.
368
+
369
+ Note that currently only encodings that are a superset of ASCII work, strings
370
+ of other encodings should be passed in as :class:`unicode`.
371
+
372
+ *object_hook* is an optional function that will be called with the result of
373
+ every JSON object decoded and its return value will be used in place of the
374
+ given :class:`dict`. This can be used to provide custom deserializations
375
+ (e.g. to support JSON-RPC class hinting).
376
+
377
+ *object_pairs_hook* is an optional function that will be called with the
378
+ result of any object literal decode with an ordered list of pairs. The
379
+ return value of *object_pairs_hook* will be used instead of the
380
+ :class:`dict`. This feature can be used to implement custom decoders that
381
+ rely on the order that the key and value pairs are decoded (for example,
382
+ :class:`collections.OrderedDict` will remember the order of insertion). If
383
+ *object_hook* is also defined, the *object_pairs_hook* takes priority.
384
+
385
+ .. versionchanged:: 2.1.0
386
+ Added support for *object_pairs_hook*.
387
+
388
+ *parse_float*, if specified, will be called with the string of every JSON
389
+ float to be decoded. By default, this is equivalent to ``float(num_str)``.
390
+ This can be used to use another datatype or parser for JSON floats
391
+ (e.g. :class:`decimal.Decimal`).
392
+
393
+ *parse_int*, if specified, will be called with the string of every JSON int
394
+ to be decoded. By default, this is equivalent to ``int(num_str)``. This can
395
+ be used to use another datatype or parser for JSON integers
396
+ (e.g. :class:`float`).
397
+
398
+ *parse_constant*, if specified, will be called with one of the following
399
+ strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to
400
+ raise an exception if invalid JSON numbers are encountered.
401
+
402
+ *strict* controls the parser's behavior when it encounters an invalid
403
+ control character in a string. The default setting of ``True`` means that
404
+ unescaped control characters are parse errors, if ``False`` then control
405
+ characters will be allowed in strings.
406
+
407
+ .. method:: decode(s)
408
+
409
+ Return the Python representation of *s* (a :class:`str` or
410
+ :class:`unicode` instance containing a JSON document)
411
+
412
+ If *s* is a :class:`str` then decoded JSON strings that contain
413
+ only ASCII characters may be parsed as :class:`str` for performance and
414
+ memory reasons. If your code expects only :class:`unicode` the
415
+ appropriate solution is decode *s* to :class:`unicode` prior to calling
416
+ decode.
417
+
418
+ :exc:`JSONDecodeError` will be raised if the given JSON
419
+ document is not valid.
420
+
421
+ .. method:: raw_decode(s)
422
+
423
+ Decode a JSON document from *s* (a :class:`str` or :class:`unicode`
424
+ beginning with a JSON document) and return a 2-tuple of the Python
425
+ representation and the index in *s* where the document ended.
426
+
427
+ This can be used to decode a JSON document from a string that may have
428
+ extraneous data at the end.
429
+
430
+ :exc:`JSONDecodeError` will be raised if the given JSON
431
+ document is not valid.
432
+
433
+ .. class:: JSONEncoder([skipkeys[, ensure_ascii[, check_circular[, allow_nan[, sort_keys[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, bigint_as_string[, item_sort_key]]]]]]]]]]]]])
434
+
435
+ Extensible JSON encoder for Python data structures.
436
+
437
+ Supports the following objects and types by default:
438
+
439
+ +-------------------+---------------+
440
+ | Python | JSON |
441
+ +===================+===============+
442
+ | dict, namedtuple | object |
443
+ +-------------------+---------------+
444
+ | list, tuple | array |
445
+ +-------------------+---------------+
446
+ | str, unicode | string |
447
+ +-------------------+---------------+
448
+ | int, long, float | number |
449
+ +-------------------+---------------+
450
+ | True | true |
451
+ +-------------------+---------------+
452
+ | False | false |
453
+ +-------------------+---------------+
454
+ | None | null |
455
+ +-------------------+---------------+
456
+
457
+ .. versionchanged:: 2.2.0
458
+ Changed *namedtuple* encoding from JSON array to object.
459
+
460
+ To extend this to recognize other objects, subclass and implement a
461
+ :meth:`default` method with another method that returns a serializable object
462
+ for ``o`` if possible, otherwise it should call the superclass implementation
463
+ (to raise :exc:`TypeError`).
464
+
465
+ If *skipkeys* is false (the default), then it is a :exc:`TypeError` to
466
+ attempt encoding of keys that are not str, int, long, float or None. If
467
+ *skipkeys* is true, such items are simply skipped.
468
+
469
+ If *ensure_ascii* is true (the default), the output is guaranteed to be
470
+ :class:`str` objects with all incoming unicode characters escaped. If
471
+ *ensure_ascii* is false, the output will be a unicode object.
472
+
473
+ If *check_circular* is false (the default), then lists, dicts, and custom
474
+ encoded objects will be checked for circular references during encoding to
475
+ prevent an infinite recursion (which would cause an :exc:`OverflowError`).
476
+ Otherwise, no such check takes place.
477
+
478
+ If *allow_nan* is true (the default), then ``NaN``, ``Infinity``, and
479
+ ``-Infinity`` will be encoded as such. This behavior is not JSON
480
+ specification compliant, but is consistent with most JavaScript based
481
+ encoders and decoders. Otherwise, it will be a :exc:`ValueError` to encode
482
+ such floats.
483
+
484
+ If *sort_keys* is true (not the default), then the output of dictionaries
485
+ will be sorted by key; this is useful for regression tests to ensure that
486
+ JSON serializations can be compared on a day-to-day basis.
487
+
488
+ If *item_sort_key* is a callable (not the default), then the output of
489
+ dictionaries will be sorted with it. The callable will be used like this:
490
+ ``sorted(dct.items(), key=item_sort_key)``. This option takes precedence
491
+ over *sort_keys*.
492
+
493
+ .. versionchanged:: 2.5.0
494
+ *item_sort_key* is new in 2.5.0.
495
+
496
+ If *indent* is a string, then JSON array elements and object members
497
+ will be pretty-printed with a newline followed by that string repeated
498
+ for each level of nesting. ``None`` (the default) selects the most compact
499
+ representation without any newlines. For backwards compatibility with
500
+ versions of simplejson earlier than 2.1.0, an integer is also accepted
501
+ and is converted to a string with that many spaces.
502
+
503
+ .. versionchanged:: 2.1.0
504
+ Changed *indent* from an integer number of spaces to a string.
505
+
506
+ If specified, *separators* should be an ``(item_separator, key_separator)``
507
+ tuple. By default, ``(', ', ': ')`` are used. To get the most compact JSON
508
+ representation, you should specify ``(',', ':')`` to eliminate whitespace.
509
+
510
+ If specified, *default* should be a function that gets called for objects
511
+ that can't otherwise be serialized. It should return a JSON encodable
512
+ version of the object or raise a :exc:`TypeError`.
513
+
514
+ If *encoding* is not ``None``, then all input strings will be transformed
515
+ into unicode using that encoding prior to JSON-encoding. The default is
516
+ ``'utf-8'``.
517
+
518
+ If *namedtuple_as_object* is true (default: ``True``),
519
+ objects with ``_asdict()`` methods will be encoded
520
+ as JSON objects.
521
+
522
+ .. versionchanged:: 2.2.0
523
+ *namedtuple_as_object* is new in 2.2.0.
524
+
525
+ .. versionchanged:: 2.3.0
526
+ *namedtuple_as_object* no longer requires that these objects be
527
+ subclasses of :class:`tuple`.
528
+
529
+ If *tuple_as_array* is true (default: ``True``),
530
+ :class:`tuple` (and subclasses) will be encoded as JSON arrays.
531
+
532
+ .. versionchanged:: 2.2.0
533
+ *tuple_as_array* is new in 2.2.0.
534
+
535
+ If *bigint_as_string* is true (default: ``False``), :class:`int`` ``2**53``
536
+ and higher or lower than ``-2**53`` will be encoded as strings. This is to
537
+ avoid the rounding that happens in Javascript otherwise. Note that this
538
+ option loses type information, so use with extreme caution.
539
+
540
+ .. versionchanged:: 2.4.0
541
+ *bigint_as_string* is new in 2.4.0.
542
+
543
+
544
+ .. method:: default(o)
545
+
546
+ Implement this method in a subclass such that it returns a serializable
547
+ object for *o*, or calls the base implementation (to raise a
548
+ :exc:`TypeError`).
549
+
550
+ For example, to support arbitrary iterators, you could implement default
551
+ like this::
552
+
553
+ def default(self, o):
554
+ try:
555
+ iterable = iter(o)
556
+ except TypeError:
557
+ pass
558
+ else:
559
+ return list(iterable)
560
+ return JSONEncoder.default(self, o)
561
+
562
+
563
+ .. method:: encode(o)
564
+
565
+ Return a JSON string representation of a Python data structure, *o*. For
566
+ example::
567
+
568
+ >>> import simplejson as json
569
+ >>> json.JSONEncoder().encode({"foo": ["bar", "baz"]})
570
+ '{"foo": ["bar", "baz"]}'
571
+
572
+
573
+ .. method:: iterencode(o)
574
+
575
+ Encode the given object, *o*, and yield each string representation as
576
+ available. For example::
577
+
578
+ for chunk in JSONEncoder().iterencode(bigobject):
579
+ mysocket.write(chunk)
580
+
581
+ Note that :meth:`encode` has much better performance than
582
+ :meth:`iterencode`.
583
+
584
+ .. class:: JSONEncoderForHTML([skipkeys[, ensure_ascii[, check_circular[, allow_nan[, sort_keys[, indent[, separators[, encoding[, default[, use_decimal[, namedtuple_as_object[, tuple_as_array[, bigint_as_string[, item_sort_key]]]]]]]]]]]]])
585
+
586
+ Subclass of :class:`JSONEncoder` that escapes &, <, and > for embedding in HTML.
587
+
588
+ .. versionchanged:: 2.1.0
589
+ New in 2.1.0
590
+
591
+ Exceptions
592
+ ----------
593
+
594
+ .. exception:: JSONDecodeError(msg, doc, pos[, end])
595
+
596
+ Subclass of :exc:`ValueError` with the following additional attributes:
597
+
598
+ .. attribute:: msg
599
+
600
+ The unformatted error message
601
+
602
+ .. attribute:: doc
603
+
604
+ The JSON document being parsed
605
+
606
+ .. attribute:: pos
607
+
608
+ The start index of doc where parsing failed
609
+
610
+ .. attribute:: end
611
+
612
+ The end index of doc where parsing failed (may be ``None``)
613
+
614
+ .. attribute:: lineno
615
+
616
+ The line corresponding to pos
617
+
618
+ .. attribute:: colno
619
+
620
+ The column corresponding to pos
621
+
622
+ .. attribute:: endlineno
623
+
624
+ The line corresponding to end (may be ``None``)
625
+
626
+ .. attribute:: endcolno
627
+
628
+ The column corresponding to end (may be ``None``)