How to use template - 10 common examples

To help you get started, we’ve selected a few template examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kattis / problemtools / problemtools / problem2html.py View on Github external
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'
github Kattis / problemtools / problemtools / problem2html.py View on Github external
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'
github hackatbrown / 2015.hackatbrown.org / hack-at-brown-2015 / registration.py View on Github external
def accept_hacker(hacker):
	#print "actually accepting hacker"
	hacker.deadline = (datetime.datetime.now() + datetime.timedelta(seconds=admission_expiration_seconds()))
	if hacker.deadline > datetime.datetime(2015, 2, 7):
		hacker.deadline = datetime.datetime(2015, 2, 7)
	email = template("emails/admitted.html", {"hacker": hacker, "deadline": hacker.deadline.strftime("%m/%d/%y"), "name":hacker.name.split(" ")[0]})
	send_email(recipients=[hacker.email], html=email, subject="You got off the Waitlist for Hack@Brown!")

	hacker.admitted_email_sent_date = datetime.datetime.now()
	hacker.put()
	memcache.add("admitted:{0}".format(hacker.secret), "1", memcache_expiry)
github heynemann / skink / skink / controllers / __init__.py View on Github external
    @authenticated()
    @template.output("pipeline_index.html")
    def edit(self, pipeline_id):
        pipelines = self.repository.get_all()
        pipeline = self.repository.get(pipeline_id)
        return template.render(authenticated=self.authenticated(), pipeline=pipeline, pipelines=pipelines, errors=None)
github semk / voldemort / voldemort / __init__.py View on Github external
move_to_site(filename, dest)
                    continue

                page_meta = template.get_meta_data(filename)
                page_url = os.path.join(
                    '/',
                    os.path.splitext(
                        page_meta['filename'].split(self.work_dir)[1][1:])[0])
                page_meta['url'] = page_url
                self.pages.append(page_meta)
                # paginate if needed
                if page_meta.get('paginate', False):
                    self.paginate(filename, page_meta)
                    continue

                html = template.render(page_meta['raw'], {'page': page_meta})
                page_path = os.path.join(
                    self.config.site_dir,
                    filename.split(self.work_dir)[1][1:])
                page_path = self.get_page_name_for_site(page_path)
                log.debug('Generating page %s' % page_path)
                # write the rendered page
                write_html(page_path, html)
github dequis / wakarimasen / staff_interface.py View on Github external
def __init__(self, admin, board=None, dest=None, page=None,
                 perpage=50, **kwargs):
        try:
            self.user = staff.check_password(admin)
        except staff.LoginError:
            Template.__init__(self, 'admin_login_template', login_task=dest)
            return
        if not dest:
            dest = HOME_PANEL

        self.admin = admin

        # TODO: Check if mod is banned.
        if not page:
            if dest in (HOME_PANEL, TRASH_PANEL):
                # Adjust for different pagination scheme. (Blame Wakaba.)
                page = 0
            else:
                page = 1
        if not str(perpage).isdigit():
            perpage = 50
github daitao / SAN / TrainCode / option.py View on Github external
parser.add_argument('--save_results', action='store_true',
                    help='save output results')

# options for residual group and feature channel reduction
parser.add_argument('--n_resgroups', type=int, default=20,
                    help='number of residual groups')
parser.add_argument('--reduction', type=int, default=16,
                    help='number of feature maps reduction')
# options for test
parser.add_argument('--testpath', type=str, default='../test/DIV2K_val_LR_our',
                    help='dataset directory for testing')
parser.add_argument('--testset', type=str, default='Set5',
                    help='dataset name for testing')

args = parser.parse_args()
template.set_template(args)

args.scale = list(map(lambda x: int(x), args.scale.split('+')))

if args.epochs == 0:
    args.epochs = 1e8

for arg in vars(args):
    if vars(args)[arg] == 'True':
        vars(args)[arg] = True
    elif vars(args)[arg] == 'False':
        vars(args)[arg] = False
github yulunzhang / RCAN / RCAN_TrainCode / code / option.py View on Github external
parser.add_argument('--save_results', action='store_true',
                    help='save output results')

# options for residual group and feature channel reduction
parser.add_argument('--n_resgroups', type=int, default=10,
                    help='number of residual groups')
parser.add_argument('--reduction', type=int, default=16,
                    help='number of feature maps reduction')
# options for test
parser.add_argument('--testpath', type=str, default='../test/DIV2K_val_LR_our',
                    help='dataset directory for testing')
parser.add_argument('--testset', type=str, default='Set5',
                    help='dataset name for testing')

args = parser.parse_args()
template.set_template(args)

args.scale = list(map(lambda x: int(x), args.scale.split('+')))

if args.epochs == 0:
    args.epochs = 1e8

for arg in vars(args):
    if vars(args)[arg] == 'True':
        vars(args)[arg] = True
    elif vars(args)[arg] == 'False':
        vars(args)[arg] = False
github muneebaadil / sisr-irl / code / option.py View on Github external
help='resume from specific checkpoint')
parser.add_argument('--print_model', action='store_true',
                    help='print model')
parser.add_argument('--save_models', action='store_true',
                    help='save all intermediate models')
parser.add_argument('--print_every', type=int, default=100,
                    help='how many batches to wait before logging training status')
parser.add_argument('--save_results', action='store_true',
                    help='save output results')
parser.add_argument('--save_branches', action='store_true',
                    help='save outputs of each branches in IRL setup')
parser.add_argument('--save_residuals', action='store_true',
                    help='save residuals of output results')

args = parser.parse_args()
template.set_template(args)

args.scale = list(map(lambda x: int(x), args.scale.split('+')))

if args.epochs == 0:
    args.epochs = 1e8

for arg in vars(args):
    if vars(args)[arg] == 'True':
        vars(args)[arg] = True
    elif vars(args)[arg] == 'False':
        vars(args)[arg] = False
github MIVRC / MSRN-PyTorch / MSRN / Train / option.py View on Github external
# Log specifications
parser.add_argument('--save', type=str, default='test',
                    help='file name to save')
parser.add_argument('--load', type=str, default='.',
                    help='file name to load')
parser.add_argument('--resume', type=int, default=0,
                    help='resume from specific checkpoint')
parser.add_argument('--save_models', action='store_true',
                    help='save all intermediate models')
parser.add_argument('--print_every', type=int, default=100,
                    help='how many batches to wait before logging training status')
parser.add_argument('--save_results', action='store_true',
                    help='save output results')

args = parser.parse_args()
template.set_template(args)

args.scale = list(map(lambda x: int(x), args.scale.split('+')))

if args.epochs == 0:
    args.epochs = 1e8

for arg in vars(args):
    if vars(args)[arg] == 'True':
        vars(args)[arg] = True
    elif vars(args)[arg] == 'False':
        vars(args)[arg] = False