Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render_code(token, body, stack, loop):
"""Render the code, ignoring all code blocks except ones with the language
set to ``file``.
"""
lang = token["lang"] or ""
if lang != "file":
raise IgnoredByContrib
file_info_data = token["text"]
file_info = FileSchema().loads(file_info_data)
# relative to the slide source
if file_info["relative"]:
base_dir = lookatme.config.SLIDE_SOURCE_DIR
else:
base_dir = os.getcwd()
full_path = os.path.join(base_dir, file_info["path"])
if not os.path.exists(full_path):
token["text"] = "File not found"
token["lang"] = "text"
raise IgnoredByContrib
def render_code(token, body, stack, loop):
lang = token["lang"] or ""
if lang != "calendar":
raise IgnoredByContrib()
today = datetime.datetime.utcnow()
return urwid.Text(calendar.month(today.year, today.month))
def inner(*args, **kwargs):
for mod in CONTRIB_MODULES:
if not hasattr(mod, fn_name):
continue
try:
return getattr(mod, fn_name)(*args, **kwargs)
except IgnoredByContrib:
pass
return fn(*args, **kwargs)
def render_code(token, body, stack, loop):
lang = token["lang"] or ""
numbered_term_match = re.match(r'terminal(\d+)', lang)
if lang != "terminal-ex" and numbered_term_match is None:
raise IgnoredByContrib
if numbered_term_match is not None:
term_data = TerminalExSchema().load({
"command": token["text"].strip(),
"rows": int(numbered_term_match.group(1)),
"init_codeblock": False,
})
else:
term_data = TerminalExSchema().loads(token["text"])
if term_data["init_text"] is not None and term_data["init_wait"] is not None:
orig_command = term_data["command"]
term_data["command"] = " ".join([shlex.quote(x) for x in [
"expect", "-c", ";".join([
'spawn -noecho {}'.format(term_data["command"]),