Annotate the rest of scripts in tools/.

This commit is contained in:
Tim Abbott 2016-10-15 22:27:55 -07:00
parent 75daba345a
commit 172809d4e2
5 changed files with 16 additions and 2 deletions

View File

@ -2,9 +2,11 @@
from __future__ import print_function
from collections import defaultdict
from typing import Any, Dict, Iterable
import ujson
def analyze_url_coverage():
# type: () -> None
fn = 'var/url_coverage.txt' # TODO: make path more robust, maybe use json suffix
calls = []
for line in open(fn):
@ -15,6 +17,7 @@ def analyze_url_coverage():
show_which_tests_ran_endpoints(calls)
def show_slow_endpoints(calls):
# type: (Iterable[Dict[str, Any]]) -> None
tups = []
for call in calls:
tups.append((call['delay'], call['url'], call['method']))
@ -30,6 +33,7 @@ def show_slow_endpoints(calls):
print()
def show_best_coverage(calls):
# type: (Iterable[Dict[str, Any]]) -> None
count = defaultdict(int) # type: Dict[str, int]
for call in calls:
@ -46,6 +50,7 @@ def show_best_coverage(calls):
print()
def show_which_tests_ran_endpoints(calls):
# type: (Iterable[Dict[str, Any]]) -> None
test_name_dct = defaultdict(list) # type: Dict[str, List[str]]
for call in calls:

View File

@ -15,6 +15,8 @@ import os
import optparse
import codecs
from typing import IO
usage = """show-last-messages --user=<bot's email address> --api-key=<bot's api key> --count=<count>
Shows the last <count> messages on all public streams.
@ -55,6 +57,7 @@ if result['result'] != 'success':
f = codecs.open("output-candidate.html", encoding='utf-8', mode="wb")
def uniwrite(f, s):
# type: (IO, str) -> None
f.write(s)
uniwrite(f, """

View File

@ -7,6 +7,7 @@ import json
from typing import Any, Dict, List
def debug(obj):
# type: (Any) -> None
print(json.dumps(obj, indent=4))
def parse_file(fn):

View File

@ -5,6 +5,8 @@ import os
import re
import sys
from typing import Iterable
# Prepare a PDF of the entire codebase, ready for printing.
#
# Depends on:
@ -131,6 +133,7 @@ doc.close()
with open('tools/print-all/tex/epilogue.tex', 'w') as f:
def print_list(title, xs):
# type: (str, Iterable[str]) -> None
f.write('\\section*{%s}\n\n' % (title,))
for x in xs:
f.write('%s\n\n' % (x.replace('_', r'\_'),))

View File

@ -14,12 +14,14 @@ os.chdir(settings.DEPLOY_ROOT)
STATIC_PATH = 'static/'
def run():
# write the file to disk
# type: () -> None
"""Builds for production, writing the output to disk"""
subprocess.check_call(['tools/node', 'node_modules/.bin/webpack'] +
['--config', 'tools/webpack.production.config.js'])
def run_watch(port):
# watch and rebuild on changes, serve file from memory via webpack-dev-server
# type: (str) -> None
"""watches and rebuilds on changes, serving files from memory via webpack-dev-server"""
subprocess.Popen(['tools/node', 'node_modules/.bin/webpack-dev-server'] +
['--config', 'tools/webpack.config.js', '--watch-poll', '--port', port])