Skip to content

Commit e0e96a1

Browse files
committed
Fix minor problem
+ Fix non-java files to be processed
1 parent 5a3eaae commit e0e96a1

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

palint.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
TURN_IN_COMMAND = 'cse11turnin {}'
2828
VERIFY_COMMAND = 'cse11verify {}'
2929

30+
README_FILE = 'README'
31+
3032
EXIT_SUCCESS = 0
3133
EXIT_FAILURE = 1
3234

@@ -185,8 +187,8 @@ def test_compile(files, optionals, libraries):
185187
class_path = ''.join(libs) + '.'
186188
cmd = 'javac -cp {} {}'
187189

188-
java_list = filter(lambda x: str(x).endswith('.java'), files)
189-
optional_list = filter(lambda x: str(x).endswith('.java'), optionals)
190+
java_list = java_files(files)
191+
optional_list = java_files(optionals)
190192

191193
result = subprocess.check_output(cmd.format(class_path, ' '.join(java_list)), shell=True)
192194
if len(result) != 0:
@@ -203,8 +205,8 @@ def test_compile(files, optionals, libraries):
203205

204206

205207
def check_style(files, optionals):
206-
java_files = ' '.join(files) + ' '.join(optionals)
207-
cmd = 'java -jar {} -c {} {}'.format(CHECKSTYLE_PATH, STYLE_CONFIG_PATH, java_files)
208+
files_argument = ' '.join(java_files(files)) + ' '.join(java_files(optionals))
209+
cmd = 'java -jar {} -c {} {}'.format(CHECKSTYLE_PATH, STYLE_CONFIG_PATH, files_argument)
208210

209211
result = subprocess.check_output(cmd, shell=True)
210212

@@ -220,14 +222,17 @@ def check_style(files, optionals):
220222
def check_line_width(files, optionals):
221223
cmd = 'grep -n \'.\\{81,\\}\' '
222224

223-
for name in files:
225+
for name in java_files(files):
224226
print('Checking line width in ' + name)
225227
os.system(cmd + name)
226228

227-
for name in optionals:
229+
for name in java_files(optionals):
228230
print('Checking line width in ' + name)
229231
os.system(cmd + name)
230232

233+
print('Checking line width in ' + README_FILE)
234+
os.system(cmd + README_FILE)
235+
231236

232237
def format_code(files, optionals):
233238
""" Format source files using google java formatter and show diff to user. """
@@ -246,7 +251,7 @@ def format_code(files, optionals):
246251
cmd = 'java -jar {} --replace {}'.format(FORMATTER_PATH, ' '.join(optionals))
247252
os.system(cmd)
248253

249-
for name in files:
254+
for name in java_files(files):
250255
print('\n')
251256
print('Showing diff of file {} ...'.format(name))
252257

@@ -258,7 +263,7 @@ def format_code(files, optionals):
258263
os.system('cp {}/{} .'.format(backup_folder, name))
259264
print('Reverted file ' + name)
260265

261-
for name in optionals:
266+
for name in java_files(optionals):
262267
print('\n')
263268
print('Showing diff of file {} ...'.format(name))
264269

@@ -296,6 +301,10 @@ def error(msg):
296301
sys.stderr.write('> \033[93m{} \033[0m\n'.format(msg))
297302

298303

304+
def java_files(file_list):
305+
return filter(lambda x: str(x).endswith('.java'), file_list)
306+
307+
299308
args = parse_args()
300309
project = args.project[0]
301310

0 commit comments

Comments
 (0)