Skip to content

Commit 4d044c0

Browse files
committed
initial support for rosettacode integration (#112)
1 parent bd05ce4 commit 4d044c0

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed
File renamed without changes.

lib/cheat_wrapper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def _visualize(query, keyword, answers, request_options, html=None): # pylint: d
209209

210210
topic_type = get_topic_type(topic)
211211
highlight = (highlight
212+
and not topic.endswith('/:list')
212213
and topic not in [":list", ":bash_completion"]
213214
and topic_type not in ["unknown"]
214215
)

lib/get_answer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import adapter.latenz
2525
import adapter.question
2626
import adapter.internal
27+
import adapter.rosetta
28+
import adapter.learnxiny
2729

2830
class Router(object):
2931

@@ -59,6 +61,7 @@ def __init__(self):
5961
"cheat": adapter.cmd.Cheat(),
6062
"fosdem": adapter.cmd.Fosdem(),
6163
"translation": adapter.cmd.Translation(),
64+
"rosetta": adapter.rosetta.Rosetta(),
6265
}
6366

6467
self._topic_list = {
@@ -89,6 +92,7 @@ def __init__(self):
8992
("learnxiny", get_learnxiny),
9093
("question", adapter.question.get_page),
9194
("fosdem", self._adapter["fosdem"].get_page),
95+
("rosetta", self._adapter["rosetta"].get_page),
9296
("tldr", self._adapter["tldr"].get_page),
9397
("internal", self._adapter["internal"].get_page),
9498
("cheat", self._adapter["cheat"].get_page),
@@ -106,7 +110,7 @@ def get_topics_list(self, skip_dirs=False, skip_internal=False):
106110
return self._cached_topics_list
107111

108112
# merging all top level lists
109-
sources_to_merge = ['tldr', 'cheat', 'cheat.sheets', 'learnxiny']
113+
sources_to_merge = ['tldr', 'cheat', 'cheat.sheets', 'learnxiny', 'rosetta']
110114
if not skip_dirs:
111115
sources_to_merge.append("cheat.sheets dir")
112116
if not skip_internal:
@@ -134,6 +138,8 @@ def __get_topic_type(topic):
134138

135139
if topic == "":
136140
return "search"
141+
if re.match('[^/]*/rosetta(/|$)', topic):
142+
return "rosetta"
137143
if topic.startswith(":"):
138144
return "internal"
139145
if topic.endswith("/:list"):

lib/globals.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@
3939
PATH_CHEAT_SHEETS_SPOOL = "/home/igor/cheat.sheets/spool/"
4040
PATH_LEARNXINY = "/home/igor/git/github.com/adambard/learnxinyminutes-docs"
4141
PATH_LATENZ = "/home/igor/git/github.com/chubin/late.nz/bin"
42+
ROSETTA_PATH = '/home/igor/git/github.com/acmeism/RosettaCodeData'
4243
else:
4344
PATH_TLDR_PAGES = os.path.join(MYDIR, "cheatsheets/tldr/*/*.md")
4445
PATH_CHEAT_PAGES = os.path.join(MYDIR, "cheatsheets/cheat/*")
4546
PATH_CHEAT_SHEETS = os.path.join(MYDIR, "cheatsheets/sheets/")
4647
PATH_CHEAT_SHEETS_SPOOL = os.path.join(MYDIR, "cheatsheets/spool/")
4748
PATH_LEARNXINY = os.path.join(MYDIR, "cheatsheets/learnxinyminutes-docs")
4849
PATH_LATENZ = os.path.join(MYDIR, "late.nz/bin")
50+
ROSETTA_PATH = os.path.join(MYDIR, "acmeism/RosettaCodeData")
4951

5052
GITHUB_REPOSITORY = {
5153
"late.nz" : 'chubin/late.nz',

0 commit comments

Comments
 (0)