2016-08-07 17:56:15 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
from lib.find_add_class import display, find
|
|
|
|
import glob
|
2016-08-29 00:09:05 +02:00
|
|
|
import argparse
|
2016-08-07 17:56:15 +02:00
|
|
|
import sys
|
|
|
|
|
|
|
|
from six.moves import filter
|
|
|
|
try:
|
|
|
|
import lister
|
|
|
|
from typing import cast, Callable, Dict, Iterable, List
|
|
|
|
except ImportError as e:
|
|
|
|
print("ImportError: {}".format(e))
|
|
|
|
print("You need to run the Zulip linters inside a Zulip dev environment.")
|
|
|
|
print("If you are using Vagrant, you can `vagrant ssh` to enter the Vagrant guest.")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
def process_files():
|
|
|
|
# type: () -> None
|
|
|
|
|
2016-08-29 00:09:05 +02:00
|
|
|
description = '''
|
2016-08-07 17:56:15 +02:00
|
|
|
Use this tool to find HTML classes that we use in our JS code.
|
|
|
|
This looks for calls to addClass, and if you use the -v option,
|
|
|
|
you will get a display of (fn, html_class) tuples that
|
|
|
|
represent addClass calls.
|
|
|
|
|
|
|
|
If you call it with no options, the tool acts as a linter, and
|
|
|
|
it will complain if it can't resolve the class for an addClass()
|
|
|
|
call.
|
|
|
|
'''
|
|
|
|
|
2016-08-29 00:09:05 +02:00
|
|
|
parser = argparse.ArgumentParser(description=description)
|
|
|
|
parser.add_argument('-v', '--verbose',
|
2016-08-07 17:56:15 +02:00
|
|
|
action='store_true', default=False,
|
2016-08-29 00:09:05 +02:00
|
|
|
help='show where calls are')
|
|
|
|
args = parser.parse_args()
|
2016-08-07 17:56:15 +02:00
|
|
|
|
|
|
|
fns = glob.glob('static/js/*.js')
|
2016-08-29 00:09:05 +02:00
|
|
|
if args.verbose:
|
2016-08-07 17:56:15 +02:00
|
|
|
display(fns)
|
|
|
|
else:
|
|
|
|
find(fns)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
process_files()
|