pygments.rb 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +3 -0
  4. data/lexers +0 -0
  5. data/lib/pygments/popen.rb +3 -2
  6. data/lib/pygments/version.rb +1 -1
  7. data/pygments.rb.gemspec +2 -1
  8. data/vendor/pygments-main/AUTHORS +20 -1
  9. data/vendor/pygments-main/CHANGES +55 -3
  10. data/vendor/pygments-main/LICENSE +1 -1
  11. data/vendor/pygments-main/MANIFEST.in +1 -1
  12. data/vendor/pygments-main/Makefile +5 -8
  13. data/vendor/pygments-main/REVISION +1 -1
  14. data/vendor/pygments-main/doc/Makefile +153 -0
  15. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  16. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  17. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  18. data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
  19. data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
  20. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
  21. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  22. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  23. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  24. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  25. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  26. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
  27. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
  28. data/vendor/pygments-main/doc/conf.py +249 -0
  29. data/vendor/pygments-main/doc/docs/api.rst +316 -0
  30. data/vendor/pygments-main/doc/docs/authors.rst +4 -0
  31. data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
  32. data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
  33. data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
  34. data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
  35. data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
  36. data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
  37. data/vendor/pygments-main/doc/docs/index.rst +66 -0
  38. data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
  39. data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
  40. data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
  41. data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
  42. data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
  43. data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
  44. data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
  45. data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
  46. data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
  47. data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
  48. data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
  49. data/vendor/pygments-main/doc/download.rst +41 -0
  50. data/vendor/pygments-main/doc/faq.rst +143 -0
  51. data/vendor/pygments-main/doc/index.rst +53 -0
  52. data/vendor/pygments-main/doc/languages.rst +151 -0
  53. data/vendor/pygments-main/doc/make.bat +190 -0
  54. data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
  55. data/vendor/pygments-main/external/autopygmentize +65 -48
  56. data/vendor/pygments-main/external/markdown-processor.py +15 -15
  57. data/vendor/pygments-main/external/moin-parser.py +1 -1
  58. data/vendor/pygments-main/external/rst-directive.py +2 -3
  59. data/vendor/pygments-main/ez_setup.py +340 -234
  60. data/vendor/pygments-main/pygments/__init__.py +4 -4
  61. data/vendor/pygments-main/pygments/cmdline.py +81 -68
  62. data/vendor/pygments-main/pygments/console.py +1 -1
  63. data/vendor/pygments-main/pygments/filter.py +1 -1
  64. data/vendor/pygments-main/pygments/filters/__init__.py +11 -9
  65. data/vendor/pygments-main/pygments/formatter.py +3 -3
  66. data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
  67. data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
  68. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  69. data/vendor/pygments-main/pygments/formatters/html.py +44 -26
  70. data/vendor/pygments-main/pygments/formatters/img.py +21 -14
  71. data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
  72. data/vendor/pygments-main/pygments/formatters/other.py +53 -6
  73. data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
  74. data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
  75. data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
  76. data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
  77. data/vendor/pygments-main/pygments/lexer.py +59 -39
  78. data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
  79. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
  81. data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
  82. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
  83. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
  84. data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
  85. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
  86. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
  87. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
  88. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
  89. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
  90. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
  91. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
  92. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
  93. data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
  94. data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
  95. data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
  96. data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
  97. data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
  98. data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
  99. data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
  100. data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
  101. data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
  102. data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
  103. data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
  104. data/vendor/pygments-main/pygments/lexers/math.py +438 -70
  105. data/vendor/pygments-main/pygments/lexers/other.py +885 -171
  106. data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
  107. data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
  108. data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
  109. data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
  110. data/vendor/pygments-main/pygments/lexers/special.py +7 -8
  111. data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
  112. data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
  113. data/vendor/pygments-main/pygments/lexers/text.py +208 -46
  114. data/vendor/pygments-main/pygments/lexers/web.py +729 -264
  115. data/vendor/pygments-main/pygments/modeline.py +1 -1
  116. data/vendor/pygments-main/pygments/plugin.py +1 -1
  117. data/vendor/pygments-main/pygments/scanner.py +1 -1
  118. data/vendor/pygments-main/pygments/sphinxext.py +153 -0
  119. data/vendor/pygments-main/pygments/style.py +3 -2
  120. data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
  121. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  122. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  123. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  124. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  125. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  126. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  127. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  128. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  129. data/vendor/pygments-main/pygments/styles/igor.py +29 -0
  130. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  131. data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
  132. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  133. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  134. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +125 -0
  135. data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
  136. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  137. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  138. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  139. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  140. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  141. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  142. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  143. data/vendor/pygments-main/pygments/styles/xcode.py +51 -0
  144. data/vendor/pygments-main/pygments/token.py +4 -1
  145. data/vendor/pygments-main/pygments/unistring.py +6 -5
  146. data/vendor/pygments-main/pygments/util.py +35 -21
  147. data/vendor/pygments-main/scripts/check_sources.py +28 -44
  148. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
  149. data/vendor/pygments-main/scripts/find_codetags.py +27 -19
  150. data/vendor/pygments-main/scripts/find_error.py +16 -13
  151. data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
  152. data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
  153. data/vendor/pygments-main/setup.py +19 -19
  154. data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
  155. data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
  156. data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
  157. data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
  158. data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
  159. data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
  160. data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
  161. data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
  162. data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
  163. data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
  164. data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
  165. data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
  166. data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
  167. data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
  168. data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
  169. data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
  170. data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
  171. data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
  172. data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
  173. data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
  174. data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
  175. data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
  176. data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
  177. data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
  178. data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
  179. data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
  180. data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
  181. data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
  182. data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
  183. data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
  184. data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
  185. data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
  186. data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
  187. data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
  188. data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
  189. data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
  190. data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
  191. data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
  192. data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
  193. data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
  194. data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
  195. data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
  196. data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
  197. data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
  198. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
  199. data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
  200. data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
  201. data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
  202. data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
  203. data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
  204. data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
  205. data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
  206. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
  207. data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
  208. data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
  209. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
  210. data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
  211. data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
  212. data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
  213. data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
  214. data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
  215. data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
  216. data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
  217. data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
  218. data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
  219. data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
  220. data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
  221. data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
  222. data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
  223. data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
  224. data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
  225. data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
  226. data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
  227. data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
  228. data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
  229. data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
  230. data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
  231. data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
  232. data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
  233. data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
  234. data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
  235. data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
  236. data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
  237. data/vendor/pygments-main/tests/run.py +14 -19
  238. data/vendor/pygments-main/tests/string_asserts.py +22 -0
  239. data/vendor/pygments-main/tests/test_basic_api.py +28 -14
  240. data/vendor/pygments-main/tests/test_cfm.py +46 -0
  241. data/vendor/pygments-main/tests/test_clexer.py +208 -3
  242. data/vendor/pygments-main/tests/test_cmdline.py +6 -5
  243. data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
  244. data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
  245. data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
  246. data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
  247. data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
  248. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  249. data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
  250. data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
  251. data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
  252. data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
  253. data/vendor/pygments-main/tests/test_token.py +3 -3
  254. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  255. data/vendor/pygments-main/tests/test_util.py +1 -1
  256. metadata +138 -51
  257. data/vendor/pygments-main/docs/generate.py +0 -472
  258. data/vendor/pygments-main/docs/src/api.txt +0 -270
  259. data/vendor/pygments-main/docs/src/authors.txt +0 -5
  260. data/vendor/pygments-main/docs/src/changelog.txt +0 -5
  261. data/vendor/pygments-main/docs/src/index.txt +0 -69
  262. data/vendor/pygments-main/docs/src/installation.txt +0 -71
  263. data/vendor/pygments-main/external/rst-directive-old.py +0 -77
  264. data/vendor/pygments-main/scripts/reindent.py +0 -291
  265. data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
  266. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
  267. data/vendor/pygments-main/tests/old_run.py +0 -138
@@ -1,291 +0,0 @@
1
- #! /usr/bin/env python
2
-
3
- # Released to the public domain, by Tim Peters, 03 October 2000.
4
- # -B option added by Georg Brandl, 2006.
5
-
6
- """reindent [-d][-r][-v] [ path ... ]
7
-
8
- -d (--dryrun) Dry run. Analyze, but don't make any changes to files.
9
- -r (--recurse) Recurse. Search for all .py files in subdirectories too.
10
- -B (--no-backup) Don't write .bak backup files.
11
- -v (--verbose) Verbose. Print informative msgs; else only names of changed files.
12
- -h (--help) Help. Print this usage information and exit.
13
-
14
- Change Python (.py) files to use 4-space indents and no hard tab characters.
15
- Also trim excess spaces and tabs from ends of lines, and remove empty lines
16
- at the end of files. Also ensure the last line ends with a newline.
17
-
18
- If no paths are given on the command line, reindent operates as a filter,
19
- reading a single source file from standard input and writing the transformed
20
- source to standard output. In this case, the -d, -r and -v flags are
21
- ignored.
22
-
23
- You can pass one or more file and/or directory paths. When a directory
24
- path, all .py files within the directory will be examined, and, if the -r
25
- option is given, likewise recursively for subdirectories.
26
-
27
- If output is not to standard output, reindent overwrites files in place,
28
- renaming the originals with a .bak extension. If it finds nothing to
29
- change, the file is left alone. If reindent does change a file, the changed
30
- file is a fixed-point for future runs (i.e., running reindent on the
31
- resulting .py file won't change it again).
32
-
33
- The hard part of reindenting is figuring out what to do with comment
34
- lines. So long as the input files get a clean bill of health from
35
- tabnanny.py, reindent should do a good job.
36
- """
37
-
38
- __version__ = "1"
39
-
40
- import tokenize
41
- import os
42
- import sys
43
-
44
- verbose = 0
45
- recurse = 0
46
- dryrun = 0
47
- no_backup = 0
48
-
49
- def usage(msg=None):
50
- if msg is not None:
51
- print >> sys.stderr, msg
52
- print >> sys.stderr, __doc__
53
-
54
- def errprint(*args):
55
- sep = ""
56
- for arg in args:
57
- sys.stderr.write(sep + str(arg))
58
- sep = " "
59
- sys.stderr.write("\n")
60
-
61
- def main():
62
- import getopt
63
- global verbose, recurse, dryrun, no_backup
64
-
65
- try:
66
- opts, args = getopt.getopt(sys.argv[1:], "drvhB",
67
- ["dryrun", "recurse", "verbose", "help",
68
- "no-backup"])
69
- except getopt.error, msg:
70
- usage(msg)
71
- return
72
- for o, a in opts:
73
- if o in ('-d', '--dryrun'):
74
- dryrun += 1
75
- elif o in ('-r', '--recurse'):
76
- recurse += 1
77
- elif o in ('-v', '--verbose'):
78
- verbose += 1
79
- elif o in ('-B', '--no-backup'):
80
- no_backup += 1
81
- elif o in ('-h', '--help'):
82
- usage()
83
- return
84
- if not args:
85
- r = Reindenter(sys.stdin)
86
- r.run()
87
- r.write(sys.stdout)
88
- return
89
- for arg in args:
90
- check(arg)
91
-
92
- def check(file):
93
- if os.path.isdir(file) and not os.path.islink(file):
94
- if verbose:
95
- print "listing directory", file
96
- names = os.listdir(file)
97
- for name in names:
98
- fullname = os.path.join(file, name)
99
- if ((recurse and os.path.isdir(fullname) and
100
- not os.path.islink(fullname))
101
- or name.lower().endswith(".py")):
102
- check(fullname)
103
- return
104
-
105
- if verbose:
106
- print "checking", file, "...",
107
- try:
108
- f = open(file)
109
- except IOError, msg:
110
- errprint("%s: I/O Error: %s" % (file, str(msg)))
111
- return
112
-
113
- r = Reindenter(f)
114
- f.close()
115
- if r.run():
116
- if verbose:
117
- print "changed."
118
- if dryrun:
119
- print "But this is a dry run, so leaving it alone."
120
- else:
121
- print "reindented", file, (dryrun and "(dry run => not really)" or "")
122
- if not dryrun:
123
- if not no_backup:
124
- bak = file + ".bak"
125
- if os.path.exists(bak):
126
- os.remove(bak)
127
- os.rename(file, bak)
128
- if verbose:
129
- print "renamed", file, "to", bak
130
- f = open(file, "w")
131
- r.write(f)
132
- f.close()
133
- if verbose:
134
- print "wrote new", file
135
- else:
136
- if verbose:
137
- print "unchanged."
138
-
139
-
140
- class Reindenter:
141
-
142
- def __init__(self, f):
143
- self.find_stmt = 1 # next token begins a fresh stmt?
144
- self.level = 0 # current indent level
145
-
146
- # Raw file lines.
147
- self.raw = f.readlines()
148
-
149
- # File lines, rstripped & tab-expanded. Dummy at start is so
150
- # that we can use tokenize's 1-based line numbering easily.
151
- # Note that a line is all-blank iff it's "\n".
152
- self.lines = [line.rstrip('\n \t').expandtabs() + "\n"
153
- for line in self.raw]
154
- self.lines.insert(0, None)
155
- self.index = 1 # index into self.lines of next line
156
-
157
- # List of (lineno, indentlevel) pairs, one for each stmt and
158
- # comment line. indentlevel is -1 for comment lines, as a
159
- # signal that tokenize doesn't know what to do about them;
160
- # indeed, they're our headache!
161
- self.stats = []
162
-
163
- def run(self):
164
- tokenize.tokenize(self.getline, self.tokeneater)
165
- # Remove trailing empty lines.
166
- lines = self.lines
167
- while lines and lines[-1] == "\n":
168
- lines.pop()
169
- # Sentinel.
170
- stats = self.stats
171
- stats.append((len(lines), 0))
172
- # Map count of leading spaces to # we want.
173
- have2want = {}
174
- # Program after transformation.
175
- after = self.after = []
176
- # Copy over initial empty lines -- there's nothing to do until
177
- # we see a line with *something* on it.
178
- i = stats[0][0]
179
- after.extend(lines[1:i])
180
- for i in range(len(stats)-1):
181
- thisstmt, thislevel = stats[i]
182
- nextstmt = stats[i+1][0]
183
- have = getlspace(lines[thisstmt])
184
- want = thislevel * 4
185
- if want < 0:
186
- # A comment line.
187
- if have:
188
- # An indented comment line. If we saw the same
189
- # indentation before, reuse what it most recently
190
- # mapped to.
191
- want = have2want.get(have, -1)
192
- if want < 0:
193
- # Then it probably belongs to the next real stmt.
194
- for j in xrange(i+1, len(stats)-1):
195
- jline, jlevel = stats[j]
196
- if jlevel >= 0:
197
- if have == getlspace(lines[jline]):
198
- want = jlevel * 4
199
- break
200
- if want < 0: # Maybe it's a hanging
201
- # comment like this one,
202
- # in which case we should shift it like its base
203
- # line got shifted.
204
- for j in xrange(i-1, -1, -1):
205
- jline, jlevel = stats[j]
206
- if jlevel >= 0:
207
- want = have + getlspace(after[jline-1]) - \
208
- getlspace(lines[jline])
209
- break
210
- if want < 0:
211
- # Still no luck -- leave it alone.
212
- want = have
213
- else:
214
- want = 0
215
- assert want >= 0
216
- have2want[have] = want
217
- diff = want - have
218
- if diff == 0 or have == 0:
219
- after.extend(lines[thisstmt:nextstmt])
220
- else:
221
- for line in lines[thisstmt:nextstmt]:
222
- if diff > 0:
223
- if line == "\n":
224
- after.append(line)
225
- else:
226
- after.append(" " * diff + line)
227
- else:
228
- remove = min(getlspace(line), -diff)
229
- after.append(line[remove:])
230
- return self.raw != self.after
231
-
232
- def write(self, f):
233
- f.writelines(self.after)
234
-
235
- # Line-getter for tokenize.
236
- def getline(self):
237
- if self.index >= len(self.lines):
238
- line = ""
239
- else:
240
- line = self.lines[self.index]
241
- self.index += 1
242
- return line
243
-
244
- # Line-eater for tokenize.
245
- def tokeneater(self, type, token, (sline, scol), end, line,
246
- INDENT=tokenize.INDENT,
247
- DEDENT=tokenize.DEDENT,
248
- NEWLINE=tokenize.NEWLINE,
249
- COMMENT=tokenize.COMMENT,
250
- NL=tokenize.NL):
251
-
252
- if type == NEWLINE:
253
- # A program statement, or ENDMARKER, will eventually follow,
254
- # after some (possibly empty) run of tokens of the form
255
- # (NL | COMMENT)* (INDENT | DEDENT+)?
256
- self.find_stmt = 1
257
-
258
- elif type == INDENT:
259
- self.find_stmt = 1
260
- self.level += 1
261
-
262
- elif type == DEDENT:
263
- self.find_stmt = 1
264
- self.level -= 1
265
-
266
- elif type == COMMENT:
267
- if self.find_stmt:
268
- self.stats.append((sline, -1))
269
- # but we're still looking for a new stmt, so leave
270
- # find_stmt alone
271
-
272
- elif type == NL:
273
- pass
274
-
275
- elif self.find_stmt:
276
- # This is the first "real token" following a NEWLINE, so it
277
- # must be the first token of the next program statement, or an
278
- # ENDMARKER.
279
- self.find_stmt = 0
280
- if line: # not endmarker
281
- self.stats.append((sline, self.level))
282
-
283
- # Count number of leading blanks.
284
- def getlspace(line):
285
- i, n = 0, len(line)
286
- while i < n and line[i] == " ":
287
- i += 1
288
- return i
289
-
290
- if __name__ == '__main__':
291
- main()
@@ -1,4 +0,0 @@
1
- import "mtl" Control.Monad.Trans
2
-
3
- main :: IO ()
4
- main = putStrLn "hello world"
@@ -1,24 +0,0 @@
1
- // MyClass.h
2
- @interface MyClass : NSObject
3
- {
4
- NSString *value;
5
- NSTextField *textField;
6
- @private
7
- NSDate *lastModifiedDate;
8
- }
9
- @property(copy, readwrite) NSString *value;
10
- @property(retain) IBOutlet NSTextField *textField;
11
- @end
12
-
13
- // MyClass.m
14
- // Class extension to declare private property
15
- @interface MyClass ()
16
- @property(retain) NSDate *lastModifiedDate;
17
- @end
18
-
19
- @implementation MyClass
20
- @synthesize value;
21
- @synthesize textField;
22
- @synthesize lastModifiedDate;
23
- // implementation continues
24
- @end
@@ -1,138 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Pygments unit tests
4
- ~~~~~~~~~~~~~~~~~~
5
-
6
- Usage::
7
-
8
- python run.py [testfile ...]
9
-
10
-
11
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
12
- :license: BSD, see LICENSE for details.
13
- """
14
-
15
- import sys, os
16
- import unittest
17
-
18
- from os.path import dirname, basename, join, abspath
19
-
20
- import pygments
21
-
22
- try:
23
- import coverage
24
- except ImportError:
25
- coverage = None
26
-
27
- testdir = abspath(dirname(__file__))
28
-
29
- failed = []
30
- total_test_count = 0
31
- error_test_count = 0
32
-
33
-
34
- def err(file, what, exc):
35
- print >>sys.stderr, file, 'failed %s:' % what,
36
- print >>sys.stderr, exc
37
- failed.append(file[:-3])
38
-
39
-
40
- class QuietTestRunner(object):
41
- """Customized test runner for relatively quiet output"""
42
-
43
- def __init__(self, testname, stream=sys.stderr):
44
- self.testname = testname
45
- self.stream = unittest._WritelnDecorator(stream)
46
-
47
- def run(self, test):
48
- global total_test_count
49
- global error_test_count
50
- result = unittest._TextTestResult(self.stream, True, 1)
51
- test(result)
52
- if not result.wasSuccessful():
53
- self.stream.write(' FAIL:')
54
- result.printErrors()
55
- failed.append(self.testname)
56
- else:
57
- self.stream.write(' ok\n')
58
- total_test_count += result.testsRun
59
- error_test_count += len(result.errors) + len(result.failures)
60
- return result
61
-
62
-
63
- def run_tests(with_coverage=False):
64
- # needed to avoid confusion involving atexit handlers
65
- import logging
66
-
67
- if sys.argv[1:]:
68
- # test only files given on cmdline
69
- files = [entry + '.py' for entry in sys.argv[1:] if entry.startswith('test_')]
70
- else:
71
- files = [entry for entry in os.listdir(testdir)
72
- if (entry.startswith('test_') and entry.endswith('.py'))]
73
- files.sort()
74
-
75
- WIDTH = 85
76
-
77
- print >>sys.stderr, \
78
- ('Pygments %s Test Suite running%s, stand by...' %
79
- (pygments.__version__,
80
- with_coverage and " with coverage analysis" or "")).center(WIDTH)
81
- print >>sys.stderr, ('(using Python %s)' % sys.version.split()[0]).center(WIDTH)
82
- print >>sys.stderr, '='*WIDTH
83
-
84
- if with_coverage:
85
- coverage.erase()
86
- coverage.start()
87
-
88
- for testfile in files:
89
- globs = {'__file__': join(testdir, testfile)}
90
- try:
91
- execfile(join(testdir, testfile), globs)
92
- except Exception, exc:
93
- raise
94
- err(testfile, 'execfile', exc)
95
- continue
96
- sys.stderr.write(testfile[:-3] + ': ')
97
- try:
98
- runner = QuietTestRunner(testfile[:-3])
99
- # make a test suite of all TestCases in the file
100
- tests = []
101
- for name, thing in globs.iteritems():
102
- if name.endswith('Test'):
103
- tests.append((name, unittest.makeSuite(thing)))
104
- tests.sort()
105
- suite = unittest.TestSuite()
106
- suite.addTests([x[1] for x in tests])
107
- runner.run(suite)
108
- except Exception, exc:
109
- err(testfile, 'running test', exc)
110
-
111
- print >>sys.stderr, '='*WIDTH
112
- if failed:
113
- print >>sys.stderr, '%d of %d tests failed.' % \
114
- (error_test_count, total_test_count)
115
- print >>sys.stderr, 'Tests failed in:', ', '.join(failed)
116
- ret = 1
117
- else:
118
- if total_test_count == 1:
119
- print >>sys.stderr, '1 test happy.'
120
- else:
121
- print >>sys.stderr, 'All %d tests happy.' % total_test_count
122
- ret = 0
123
-
124
- if with_coverage:
125
- coverage.stop()
126
- modules = [mod for name, mod in sys.modules.iteritems()
127
- if name.startswith('pygments.') and mod]
128
- coverage.report(modules)
129
-
130
- return ret
131
-
132
-
133
- if __name__ == '__main__':
134
- with_coverage = False
135
- if sys.argv[1:2] == ['-C']:
136
- with_coverage = bool(coverage)
137
- del sys.argv[1]
138
- sys.exit(run_tests(with_coverage))