Skip to content
This repository was archived by the owner on Apr 2, 2019. It is now read-only.

Commit 1d77ecc

Browse files
committedSep 20, 2013
Fix the package to work when zipped
1 parent 2fef8e1 commit 1d77ecc

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed
 

‎__main__.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import json
2+
import sys
3+
4+
5+
def main(filename, path):
6+
from checker import get_problems
7+
with open(filename, 'rb') as f:
8+
source = f.read()
9+
if sys.version_info[0] >= 3:
10+
source = source.decode('utf-8')
11+
problems = get_problems(source, path)
12+
json.dump(problems, sys.stdout)
13+
14+
15+
if __name__ == '__main__':
16+
if len(sys.argv) == 3:
17+
main(sys.argv[1], sys.argv[2])
18+
else:
19+
print('Usage: %s %s <filename> <path>' % (sys.executable, sys.argv[0]))

‎checker.py

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ast
22
from collections import namedtuple
3+
import os.path
34
import sys
45
import tempfile
56

@@ -64,25 +65,9 @@ def get_external(source, filename, executable):
6465
import subprocess
6566
with tempfile.NamedTemporaryFile() as tf:
6667
tf.write(source.encode('utf-8'))
67-
output = subprocess.check_output([executable, __file__, tf.name,
68-
filename])
68+
output = subprocess.check_output([executable,
69+
os.path.dirname(__file__),
70+
tf.name, filename])
6971
problems = json.loads(output.decode('utf-8'))
7072
problems = [Problem(*p) for p in problems]
7173
return problems
72-
73-
74-
def main(filename, path):
75-
import json
76-
with open(filename, 'rb') as f:
77-
source = f.read()
78-
if sys.version_info[0] >= 3:
79-
source = source.decode('utf-8')
80-
problems = get_problems(source, path)
81-
json.dump(problems, sys.stdout)
82-
83-
84-
if __name__ == '__main__':
85-
if len(sys.argv) == 3:
86-
main(sys.argv[1], sys.argv[2])
87-
else:
88-
print('Usage: %s %s <filename> <path>' % (sys.executable, sys.argv[0]))

‎plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from . import checker
77

8-
PACKAGE_NAME = os.path.basename(os.path.dirname(__file__))
8+
PACKAGE_NAME = os.path.splitext(os.path.basename(os.path.dirname(__file__)))[0]
99

1010

1111
class Validator(sublime_plugin.EventListener):

0 commit comments

Comments
 (0)
This repository has been archived.