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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +40 -0
- data/README.md +3 -0
- data/lexers +0 -0
- data/lib/pygments/popen.rb +3 -2
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -1
- data/vendor/pygments-main/AUTHORS +20 -1
- data/vendor/pygments-main/CHANGES +55 -3
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/MANIFEST.in +1 -1
- data/vendor/pygments-main/Makefile +5 -8
- data/vendor/pygments-main/REVISION +1 -1
- data/vendor/pygments-main/doc/Makefile +153 -0
- data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
- data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
- data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
- data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
- data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
- data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
- data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
- data/vendor/pygments-main/doc/conf.py +249 -0
- data/vendor/pygments-main/doc/docs/api.rst +316 -0
- data/vendor/pygments-main/doc/docs/authors.rst +4 -0
- data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
- data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
- data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
- data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
- data/vendor/pygments-main/doc/docs/index.rst +66 -0
- data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
- data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
- data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
- data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
- data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
- data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
- data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
- data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
- data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
- data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
- data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
- data/vendor/pygments-main/doc/download.rst +41 -0
- data/vendor/pygments-main/doc/faq.rst +143 -0
- data/vendor/pygments-main/doc/index.rst +53 -0
- data/vendor/pygments-main/doc/languages.rst +151 -0
- data/vendor/pygments-main/doc/make.bat +190 -0
- data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
- data/vendor/pygments-main/external/autopygmentize +65 -48
- data/vendor/pygments-main/external/markdown-processor.py +15 -15
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +2 -3
- data/vendor/pygments-main/ez_setup.py +340 -234
- data/vendor/pygments-main/pygments/__init__.py +4 -4
- data/vendor/pygments-main/pygments/cmdline.py +81 -68
- data/vendor/pygments-main/pygments/console.py +1 -1
- data/vendor/pygments-main/pygments/filter.py +1 -1
- data/vendor/pygments-main/pygments/filters/__init__.py +11 -9
- data/vendor/pygments-main/pygments/formatter.py +3 -3
- data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
- data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +44 -26
- data/vendor/pygments-main/pygments/formatters/img.py +21 -14
- data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
- data/vendor/pygments-main/pygments/formatters/other.py +53 -6
- data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
- data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
- data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
- data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
- data/vendor/pygments-main/pygments/lexer.py +59 -39
- data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
- data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
- data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
- data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
- data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
- data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
- data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
- data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
- data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
- data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
- data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
- data/vendor/pygments-main/pygments/lexers/math.py +438 -70
- data/vendor/pygments-main/pygments/lexers/other.py +885 -171
- data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
- data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
- data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
- data/vendor/pygments-main/pygments/lexers/special.py +7 -8
- data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
- data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
- data/vendor/pygments-main/pygments/lexers/text.py +208 -46
- data/vendor/pygments-main/pygments/lexers/web.py +729 -264
- data/vendor/pygments-main/pygments/modeline.py +1 -1
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +1 -1
- data/vendor/pygments-main/pygments/sphinxext.py +153 -0
- data/vendor/pygments-main/pygments/style.py +3 -2
- data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
- data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
- data/vendor/pygments-main/pygments/styles/borland.py +1 -1
- data/vendor/pygments-main/pygments/styles/bw.py +1 -1
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
- data/vendor/pygments-main/pygments/styles/default.py +1 -1
- data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
- data/vendor/pygments-main/pygments/styles/igor.py +29 -0
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
- data/vendor/pygments-main/pygments/styles/native.py +1 -1
- data/vendor/pygments-main/pygments/styles/paraiso_dark.py +125 -0
- data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/tango.py +1 -1
- data/vendor/pygments-main/pygments/styles/trac.py +1 -1
- data/vendor/pygments-main/pygments/styles/vim.py +1 -1
- data/vendor/pygments-main/pygments/styles/vs.py +1 -1
- data/vendor/pygments-main/pygments/styles/xcode.py +51 -0
- data/vendor/pygments-main/pygments/token.py +4 -1
- data/vendor/pygments-main/pygments/unistring.py +6 -5
- data/vendor/pygments-main/pygments/util.py +35 -21
- data/vendor/pygments-main/scripts/check_sources.py +28 -44
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
- data/vendor/pygments-main/scripts/find_codetags.py +27 -19
- data/vendor/pygments-main/scripts/find_error.py +16 -13
- data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
- data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
- data/vendor/pygments-main/setup.py +19 -19
- data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
- data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
- data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
- data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
- data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
- data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
- data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
- data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
- data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
- data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
- data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
- data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
- data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
- data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
- data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
- data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
- data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
- data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
- data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
- data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
- data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
- data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
- data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
- data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
- data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
- data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
- data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
- data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
- data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
- data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
- data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
- data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
- data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
- data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
- data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
- data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
- data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
- data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
- data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
- data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
- data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
- data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
- data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
- data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
- data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
- data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
- data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
- data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
- data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
- data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
- data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
- data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
- data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
- data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
- data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
- data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
- data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
- data/vendor/pygments-main/tests/run.py +14 -19
- data/vendor/pygments-main/tests/string_asserts.py +22 -0
- data/vendor/pygments-main/tests/test_basic_api.py +28 -14
- data/vendor/pygments-main/tests/test_cfm.py +46 -0
- data/vendor/pygments-main/tests/test_clexer.py +208 -3
- data/vendor/pygments-main/tests/test_cmdline.py +6 -5
- data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
- data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
- data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
- data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
- data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
- data/vendor/pygments-main/tests/test_perllexer.py +1 -1
- data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
- data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
- data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
- data/vendor/pygments-main/tests/test_token.py +3 -3
- data/vendor/pygments-main/tests/test_using_api.py +1 -1
- data/vendor/pygments-main/tests/test_util.py +1 -1
- metadata +138 -51
- data/vendor/pygments-main/docs/generate.py +0 -472
- data/vendor/pygments-main/docs/src/api.txt +0 -270
- data/vendor/pygments-main/docs/src/authors.txt +0 -5
- data/vendor/pygments-main/docs/src/changelog.txt +0 -5
- data/vendor/pygments-main/docs/src/index.txt +0 -69
- data/vendor/pygments-main/docs/src/installation.txt +0 -71
- data/vendor/pygments-main/external/rst-directive-old.py +0 -77
- data/vendor/pygments-main/scripts/reindent.py +0 -291
- data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
- 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,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))
|