Skip to content

Commit c372802

Browse files
committed
added late.nz support (/latencies)
1 parent b6ba55a commit c372802

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/cheat_wrapper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ def _visualize(query, keyword, answers, request_options, html=None): # pylint: d
228228

229229
if topic_type == "internal" and highlight:
230230
answer = _colorize_internal(topic, answer, html)
231+
elif topic_type == "late.nz":
232+
pass
231233
else:
232234
answer = _colorize_ansi_answer(
233235
topic, answer, color_style,

lib/get_answer.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
patch_all()
1515

1616
# pylint: disable=wrong-import-position,wrong-import-order
17+
import sys
1718
import collections
1819
import glob
1920
import os
@@ -25,7 +26,8 @@
2526
import time
2627

2728
import beautifier
28-
from globals import MYDIR, PATH_TLDR_PAGES, PATH_CHEAT_PAGES, PATH_CHEAT_SHEETS, COLOR_STYLES, REDISHOST
29+
from globals import MYDIR, PATH_TLDR_PAGES, PATH_CHEAT_PAGES, PATH_CHEAT_SHEETS, PATH_LATENZ, \
30+
COLOR_STYLES, REDISHOST
2931
from adapter_learnxiny import get_learnxiny, get_learnxiny_list, is_valid_learnxy
3032
from languages_data import LANGUAGE_ALIAS, SO_NAME, rewrite_editor_section_name
3133
from colorize_internal import colorize_internal
@@ -177,6 +179,9 @@ def get_topic_type(topic): # pylint: disable=too-many-locals,too-many-branches,t
177179
# let us activate the 'question' feature for all subsections
178180
result = 'question'
179181

182+
if topic.lower() in ['latencies', 'late.nz', 'latency']:
183+
result = 'late.nz'
184+
180185
if result == 'unknown' or result == 'question':
181186
print("result = ", result)
182187
print(CHEAT_SHEETS_TOPICS)
@@ -328,11 +333,17 @@ def _get_unknown(topic):
328333
%s
329334
""" % possible_topics_text
330335

336+
def _get_latenz(topic):
337+
sys.path.append(PATH_LATENZ)
338+
import latencies
339+
return latencies.render()
340+
331341
# pylint: disable=bad-whitespace
332342
#
333343
# topic_type, function_getter
334344
# should be replaced with a decorator
335345
TOPIC_GETTERS = (
346+
('late.nz', _get_latenz),
336347
("cheat.sheets", _get_cheat_sheets),
337348
("cheat.sheets dir", _get_cheat_sheets_dir),
338349
("tldr", _get_tldr),

0 commit comments

Comments
 (0)