Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
problembase = os.path.splitext(os.path.basename(problem))[0]
destdir = Template(options.destdir).safe_substitute(problem=problembase)
destfile = Template(options.destfile).safe_substitute(problem=problembase)
imgbasedir = Template(options.imgbasedir).safe_substitute(problem=problembase)
if options.quiet:
disableLogging()
else:
getLogger().setLevel(eval("logging." + options.loglevel.upper()))
getLogger('status').setLevel(eval("logging." + options.loglevel.upper()))
texfile = problem
# Set up template if necessary
templ = None
if os.path.isdir(problem):
templ = template.Template(problem, language=options.language, title=options.title)
texfile = templ.get_file_name()
origcwd = os.getcwd()
# Setup parser and renderer etc
tex = TeX(file=texfile)
ProblemsetMacros.init(tex)
tex.ownerDocument.config['general']['copy-theme-extras'] = options.css
if not options.headers:
tex.ownerDocument.userdata['noheaders'] = True
tex.ownerDocument.config['files']['filename'] = destfile
tex.ownerDocument.config['images']['filenames'] = 'img-$num(4)'
tex.ownerDocument.config['images']['enabled'] = False
tex.ownerDocument.config['images']['imager'] = 'none'
problembase = os.path.splitext(os.path.basename(problem))[0]
destdir = Template(options.destdir).safe_substitute(problem=problembase)
destfile = Template(options.destfile).safe_substitute(problem=problembase)
imgbasedir = Template(options.imgbasedir).safe_substitute(problem=problembase)
if options.quiet:
disableLogging()
else:
getLogger().setLevel(eval("logging." + options.loglevel.upper()))
getLogger('status').setLevel(eval("logging." + options.loglevel.upper()))
texfile = problem
# Set up template if necessary
templ = None
if os.path.isdir(problem):
templ = template.Template(problem, language=options.language, title=options.title)
texfile = templ.get_file_name()
origcwd = os.getcwd()
# Setup parser and renderer etc
tex = TeX(file=texfile)
ProblemsetMacros.init(tex)
tex.ownerDocument.config['general']['copy-theme-extras'] = options.css
if not options.headers:
tex.ownerDocument.userdata['noheaders'] = True
tex.ownerDocument.config['files']['filename'] = destfile
tex.ownerDocument.config['images']['filenames'] = 'img-$num(4)'
tex.ownerDocument.config['images']['enabled'] = False
tex.ownerDocument.config['images']['imager'] = 'none'
else:
# post_comment() does permissions checking itself,
# and the caller has already done it too, so we don't
# do it a *third* time; we just go straight.
res = context.model.post_comment(comdata, context,
whois, whourl)
if res:
context.setvar(":comment:post", "good")
else:
context.setvar(":comment:post", "bad")
comment_posted(context)
# :comment:post now holds what happened, so we let the top
# level template dispatch off it to figure out what to do.
to = context.model.get_template("comment/posting.tmpl")
resp.html(template.Template(to).render(context))
context.unrel_time()
return True
def loginerror(ctx, resp):
ctx.unrel_time()
to = ctx.model.get_template("login-error.tmpl", False)
if not to:
resp.error("Your login attempt was unsuccessful. Please try again. (We apologize for the terseness here, but our normal friendly login failure page is broken.)")
else:
resp.html(template.Template(to).render(ctx))
# reset the auto-expansion of nodes
common.app_tree.auto_expand = True
os.chdir(old_dir)
return False
if not is_filelike:
infile.close()
common.app_tree.select_item(common.app_tree.root)
common.app_tree.root.widget.show_properties()
common.property_panel.Reparent(self.frame2)
# reset the auto-expansion of nodes
common.app_tree.auto_expand = True
common.app_tree.expand()
if common.app_tree.app.is_template:
print _("Loaded template")
common.app_tree.app.template_data = template.Template(infilename)
common.app_tree.app.filename = None
end = time.clock()
print _('Loading time: %.5f') % (end-start)
common.app_tree.app.saved = True
if hasattr(self, 'file_history') and infilename is not None and \
add_to_history and (not common.app_tree.app.is_template):
self.file_history.AddFileToHistory(misc.wxstr(infilename))
# ALB 2004-10-15
if config.preferences.autosave and self.autosave_timer is not None:
self.autosave_timer.Start()
self.user_message(_("Loaded %s (%.2f seconds)") % \
def make_first_time_setup_gateway():
# TODO: Make sure we're in secure mode (HTTPS)
return Template('first_time_setup')
def process_dir(root_dir, subdir, template):
curr_dir = os.path.join(root_dir, subdir)
# Look for template in current dir
template_file = os.path.join(curr_dir, config.TEMPLATE_FILE)
if os.path.exists(template_file):
template = Template(template_file)
# look for images in current dir to process
paths = config.Paths(os.path.join(args['output_dir'], subdir))
exts = ('*.png', '*.jpg')
omr_files = sorted(
[f for ext in exts for f in glob(os.path.join(curr_dir, ext))])
# Exclude marker image if exists
if(template and template.marker_path):
omr_files = [f for f in omr_files if f != template.marker_path]
subfolders = sorted([file for file in os.listdir(
curr_dir) if os.path.isdir(os.path.join(curr_dir, file))])
if omr_files:
args_local = args.copy()
if("OverrideFlags" in template.options):
def errortitle(context):
"""Generate the title for an error from a template in _errors/_,
if the template exists; otherwise uses a default. Only usable
during generation of an error page."""
if ":error:error" not in context:
return ''
(etype, to) = errorTemplate(context, "title")
if to:
return template.Template(to).render(context)
elif etype in title_map:
return title_map[etype] % context[":error:code"]
else:
return default_title % context[":error:code"]
htmlrends.register("error::title", errortitle)