├── .gitignore
├── .gitmodules
├── Commands
├── Validate Syntax Quick.tmCommand
└── Validate Syntax.tmCommand
├── README.rst
├── Support
└── bin
│ ├── pyflakes_html.py
│ └── pyflakes_quick.py
└── info.plist
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | .tmDelta
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "Support/bin/pyflakes"]
2 | path = Support/bin/pyflakes
3 | url = git://github.com/dcramer/pyflakes.git
4 |
--------------------------------------------------------------------------------
/Commands/Validate Syntax Quick.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | saveActiveFile
7 | command
8 | # runs on save; only notifies you if it raises a warning or error
9 | PYTHONPATH="$TM_BUNDLE_SUPPORT/bin/":$PYTHONPATH "${TM_PYTHON:-python}" "$TM_BUNDLE_SUPPORT/bin/pyflakes_quick.py" "$TM_FILEPATH"
10 | input
11 | none
12 | keyEquivalent
13 | @s
14 | name
15 | Validate Syntax Quick
16 | output
17 | showAsTooltip
18 | scope
19 | source.python
20 | uuid
21 | 7785C4AD-8DA8-4E0E-B5B5-1B1F1027F3C9
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Commands/Validate Syntax.tmCommand:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | beforeRunningCommand
6 | saveActiveFile
7 | bundleUUID
8 | E4A0D653-1058-42CF-91C5-52D78242CC7A
9 | capturePattern
10 | ^(.*)\s+line:\s+(\d+)\s+col:\s+(\d+).*$
11 | columnCaptureRegister
12 | 3
13 | command
14 | . "$TM_SUPPORT_PATH/lib/webpreview.sh"
15 | html_header "Validate Python"
16 | PYTHONPATH="$TM_BUNDLE_SUPPORT/bin/":$PYTHONPATH "${TM_PYTHON:-python}" "$TM_BUNDLE_SUPPORT/bin/pyflakes_html.py"
17 | html_footer
18 |
19 | fallbackInput
20 | document
21 | fileCaptureRegister
22 | 1
23 | input
24 | document
25 | keyEquivalent
26 | ~V
27 | lineCaptureRegister
28 | 2
29 | name
30 | Validate Syntax
31 | output
32 | showAsHTML
33 | scope
34 | source.python
35 | uuid
36 | C2C6DC11-73FF-4014-BA70-699876963185
37 |
38 |
39 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | Python Tools TextMate Bundle
2 | ============================
3 |
4 | Installation
5 | ------------
6 |
7 | 1. Clone the repository from GitHub.
8 |
9 | ::
10 |
11 | git clone https://github.com/dcramer/python-tools-tmbundle.git ~/Library/Application\ Support/TextMate/Bundles/PythonTools.tmbundle
12 | cd ~/Library/Application\ Support/TextMate/Bundles/PythonTools.tmbundle
13 | git submodule update --init
14 | git submodule foreach git pull origin master
15 |
16 | 2. Reload TextMate or Navigate to Bundles -> Bundle Editor -> Reload Bundles.
17 |
18 | PyFlakes
19 | --------
20 |
21 | * *Validate Syntax* (⇧⌥V) validates the syntax of the file using PyFlakes and shows the results in a new window.
22 | * *Validate Syntax Quick* (⌘S) same as above except that instead of a dedicated window you simply get a tooltip showing the the errors and warnings.
23 |
24 | Credits
25 | -------
26 |
27 | Based on the `JavaScript Tools Bundle `_.
--------------------------------------------------------------------------------
/Support/bin/pyflakes_html.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | Implementation of the command-line I{pyflakes} tool.
4 | """
5 |
6 | import sys
7 | import os
8 |
9 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pyflakes'))
10 |
11 | from pyflakes.scripts.pyflakes import check
12 |
13 | checker = __import__('pyflakes.checker').checker
14 |
15 | HTML = """
16 |
17 |
18 | PyFlakes Results
19 |
56 |
57 |
58 | Python Lint
59 | %(results)s
60 |
61 |
64 |
65 |
66 | """
67 |
68 | def main():
69 | # import re
70 | # lineno = re.compile(r'^(\d+)\:')
71 | results = {'E': 0, 'W': 0}
72 | output, warnings = [], []
73 |
74 | filepath = os.environ['TM_FILEPATH']
75 |
76 | warnings += check(sys.stdin.read(), filepath)
77 |
78 | for warning in warnings:
79 | # line = lineno.sub('' % dict(
80 | # filepath=warning.filename,
81 | # lineno=warning.lineno,
82 | # col=warning.col,
83 | # ), str(warning))
84 | output.append('%(filename)s:%(lineno)s%(message)s
' % dict(
85 | col=warning.col,
86 | lineno=warning.lineno,
87 | filepath=warning.filename,
88 | filename=os.path.basename(warning.filename),
89 | message=warning.message % warning.message_args,
90 | ))
91 | results[warning.level] += 1
92 |
93 | output = "\n\n".join(output)
94 |
95 | print HTML % dict(
96 | output=output,
97 | results='%d error(s), %d warning(s)' % (results['E'], results['W']),
98 | )
99 |
100 | if __name__ == '__main__':
101 | main()
102 |
--------------------------------------------------------------------------------
/Support/bin/pyflakes_quick.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | Implementation of the command-line I{pyflakes} tool.
4 | """
5 | import os.path
6 | import sys
7 |
8 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pyflakes'))
9 |
10 | from pyflakes.scripts.pyflakes import check
11 |
12 | def main():
13 | content = open(sys.argv[-1], 'r').read()
14 |
15 | warnings = check(content, '')
16 | for warning in warnings:
17 | print warning
18 |
19 | if __name__ == '__main__':
20 | main()
--------------------------------------------------------------------------------
/info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | name
6 | Python Tools Bundle
7 | ordering
8 |
9 | C2C6DC11-73FF-4014-BA70-699876963185
10 | 7785C4AD-8DA8-4E0E-B5B5-1B1F1027F3C9
11 |
12 | uuid
13 | 6C5B9CF0-3D29-41C0-B3AD-608F681A159E
14 |
15 |
16 |
--------------------------------------------------------------------------------