Exemplo n.º 1
0
 def _build_initial_source(self, filename):
     # generat the source from template
     template_path = self.path.get_rst_template_path()
     template = get_template(template_path)
     params = self._get_params(filename)
     source = template.substitute(params)
     return source
Exemplo n.º 2
0
 def _get_template(self, platform, prefix_dir):
     template = get_template(self._get_template_filename(platform))
     context = {
         'prefix': prefix_dir,
         'configure-options': self._configure_options,
     }
     return template.substitute(**context)
Exemplo n.º 3
0
 def get(self):
     template_name = 'bookmarks_list_partial.jinja'
     t = utils.get_template(template_name)
     htmlstr = t.render({
         'bookmarks': self.cb,
         'bookmarks_iter': iter(self.cb)})
     self.write(htmlstr)
Exemplo n.º 4
0
Arquivo: app.py Projeto: westurner/pbm
 def get(self):
     t = utils.get_template(self.template_path)
     htmlstr = t.render({
         'bookmarks': self.cb,
         'bookmarks_iter': iter(self.cb),
         'format_longdate': format_longdate,
         'rdf_uri_escape': rdf_uri_escape})
     self.write(htmlstr)
Exemplo n.º 5
0
 def _get_android_template(self, task_context, prefix_dir, platform):
     template = get_template('openssl-android-build.sh')
     context = {
         'prefix': prefix_dir,
         'sdk-root': task_context['android-sdk-home'],
         'ndk-root': task_context['android-ndk-home'],
     }
     return template.substitute(**context)
Exemplo n.º 6
0
 def get(self):
     template_name = 'bookmarks_tree_partial.jinja'
     t = utils.get_template(template_name)
     htmlstr = t.render({
         'bookmarks': self.cb,
         'bookmarks_iter': iter(self.cb),
         'format_longdate': format_longdate,
         'rdf_uri_escape': rdf_uri_escape})
     self.write(htmlstr)
Exemplo n.º 7
0
def index(request):
	nav = Nav.objects.all()
	data = {
		"nav_top": [n for n in nav if n.position == "top"],
		"nav_middle": [n for n in nav if n.position == "middle"],
		"nav_bottom": [n for n in nav if n.position == "bottom"],
		"categories": Tree(list(Category.objects.all().values())),
	}
	return render_to_response(get_template("index.html"), {"data": data})
Exemplo n.º 8
0
    def get(self):
        if not self.current_user:
            self.redirect("/login")
            return
#        name = tornado.escape.xhtml_escape(self.current_user)
#        self.write("Hello, " + name)
        template_name = 'main.jinja'
        t = utils.get_template(template_name)
        htmlstr = t.render({'name': self.current_user})
        self.write(htmlstr)
Exemplo n.º 9
0
def _format_file(sections):
	tplf = open( get_template('header'), 'r' )
	tpl = os.linesep.join( re.split(r'\r\n|\r|\n', tplf.read() ) )
	tplf.close()

	tpl = tpl.replace('%GUARD_NAME%', _build_include_guard(sections) )
	tpl = tpl.replace('%NAMESPACE_BEGIN%', _build_namespace_begin(sections) )
	tpl = tpl.replace('%NAMESPACE_END%', _build_namespace_end(sections) )

	hdrf = open(build_target_file_path(sections, 'hpp', EVIPP_HEADER_GENERATOR_BASE_DIR), 'w')
	hdrf.write(tpl)
	hdrf.close()
Exemplo n.º 10
0
def email_list(request):
    """
    All email address associated with User account will be passed into the template as a list
    An ``add`` email form will be passed in the template so user can add new email inline
    """
    form = EmailAddressForm(user=request.user)
    emails_list = EmailAddress.objects.filter(user=request.user).order_by(
        *sort_email())
    return render_to_response(get_template('emailmgr_email_list.html'), {
        'email_list': emails_list,
        'email_form': form
    },
                              context_instance=RequestContext(request))
Exemplo n.º 11
0
 def _write_setenv_android(self, build_dir, platform):
     template = get_template('setenv-android.sh')
     aarch, eabi = arch_to_setenv_info(platform)
     context = {
         #see NDK_HOME/toolchains/
         #x86-4.9, arm-linux-androideabi-4.6, etc
         'eabi': eabi,
         #x86 or arm (nothing else supported by script)
         'arch': aarch,
         'api': '19',
     }
     write_to_file(join(build_dir, 'setenv-android.sh'),
                   template.substitute(**context))
Exemplo n.º 12
0
def _format_file(sections):
    tplf = open(get_template('header'), 'r')
    tpl = os.linesep.join(re.split(r'\r\n|\r|\n', tplf.read()))
    tplf.close()

    tpl = tpl.replace('%GUARD_NAME%', _build_include_guard(sections))
    tpl = tpl.replace('%NAMESPACE_BEGIN%', _build_namespace_begin(sections))
    tpl = tpl.replace('%NAMESPACE_END%', _build_namespace_end(sections))

    hdrf = open(
        build_target_file_path(sections, 'hh',
                               EVIPP_HEADER_GENERATOR_BASE_DIR), 'w')
    hdrf.write(tpl)
    hdrf.close()
Exemplo n.º 13
0
def email_list(request):
    """
    All email address associated with User account will be passed into the template as a list
    An ``add`` email form will be passed in the template so user can add new email inline
    """
    form = EmailAddressForm(user=request.user)
    emails_list = EmailAddress.objects.filter(user=request.user).order_by(*sort_email())
    return render_to_response(get_template('emailmgr_email_list.html'),
                              {
                                'email_list': emails_list,
                                'email_form': form
                              },
                              context_instance=RequestContext(request)
                              )
Exemplo n.º 14
0
def goods_detail(request, id):
	nav = Nav.objects.all()
	goods = Goods.objects.get(id=id)
	props = json.loads(goods.properties)
	spec = Specification.objects.filter(id__in=props["spec"])
	data = {
		"nav_top": [n for n in nav if n.position == "top"],
		"nav_middle": [n for n in nav if n.position == "middle"],
		"nav_bottom": [n for n in nav if n.position == "bottom"],
		"categories": Tree(list(Category.objects.all().values())),
		"goods": goods,
		"spec": spec,
		"specitem": json.dumps(props["specitem"]),
	}
	return render_to_response(get_template("goods_detail.html"), {"data": data})
Exemplo n.º 15
0
def send_mail(item):
    config = get_data_from_config()
    user = config[USER]
    smtpObj = smtplib.SMTP(config[SERVER])
    smtpObj.ehlo()
    smtpObj.starttls()
    smtpObj.login(user, config[PASSWORD])
    html = get_template(f'./web/templates/{item[TEMPLATE]}', item)
    msg = MIMEMultipart('alternative')
    msg.attach(MIMEText(html, 'html'))
    msg['Subject'] = 'Subject'
    msg['From'] = user
    # https://tempail.com/ru/ - copy temp mail and test
    smtpObj.sendmail(user, item['email'], msg.as_string())
    smtpObj.quit()
Exemplo n.º 16
0
 def _get_android_template(self, task_context, prefix_dir, platform):
     template = get_template('sqlcipher-android-build.sh')
     aarch, eabi = arch_to_setenv_info(platform)
     context = {
         'prefix': prefix_dir,
         'ndk-home': task_context['android-ndk-home'],
         'api': '19',
         'eabi': eabi,
         'host': get_android_configure_host_type(platform),
         #arm/mips/x86
         'arch': aarch,
         #FIXME
         #this is the building system's platform
         'host-arch': 'linux-x86_64',
     }
     return template.substitute(**context)
Exemplo n.º 17
0
    def _copy_build_templates(self, build_dir, task_context,
                              desktop_platforms):
        for platform in desktop_platforms:
            prefix_dir = join(task_context['root-prefix-path'], platform)

            template = get_template('sqlite4java-build-%s.properties' %
                                    platform)

            context = {
                'prefix':
                prefix_dir,
                'jdk-home':
                task_context['%s-jdk-home' % get_os_from_platform(platform)],
            }

            path = join(build_dir, 'ant', 'build-%s.properties' % platform)
            write_to_file(path, template.substitute(**context))
Exemplo n.º 18
0
def write_html_email(subject, values, template_name):
    """
        Sends a email using the template and the values for the template with the given subject.
    :param subject: subject which should be used for the email.
    :param values: dictionary which is needed by the template.
    :param template_name: filename of the template which should be used within the templates folder.
    """
    msg = MIMEMultipart('alternative')
    msg['Subject'] = subject
    msg['From'] = config.get_value_from_config('mailAddress', Section.EMAIL)
    msg['To'] = config.get_value_from_config('mailAddress', Section.EMAIL)
    template = utils.get_template(template_name)
    html = template.render(**values)
    part1 = MIMEText(html, 'html')
    msg.attach(part1)
    server = get_server_object()
    LOG.info('Writing email to %s with %s with the subject %s and we are using the template %s.', msg['To'],
             msg['From'], msg['Subject'], template_name)
    server.sendmail(msg['From'], msg['To'], msg.as_string())
    server.close()
Exemplo n.º 19
0
def email_add(request):
    """
    User is logged and has a primary email address already
    This will add an aditional email address to this User
    """
    if request.method == 'POST':
        form = EmailAddressForm(user=request.user, data=request.POST)
        if form.is_valid():
            email = form.save()
            user_added_email.send(sender=EmailAddress, email_address=email)
            Msg.add_message(request, Msg.SUCCESS, _('email address added'))
            form = EmailAddressForm(user=request.user)
    else:
        form = EmailAddressForm(user=request.user)
    emails_list = EmailAddress.objects.filter(user=request.user).order_by(
        *sort_email())
    return render_to_response(get_template('emailmgr_email_list.html'), {
        'email_list': emails_list,
        'email_form': form
    },
                              context_instance=RequestContext(request))
Exemplo n.º 20
0
def email_add(request):
    """
    User is logged and has a primary email address already
    This will add an aditional email address to this User
    """
    if request.method == 'POST':
        form = EmailAddressForm(user=request.user, data=request.POST)
        if form.is_valid():
            email = form.save()
            user_added_email.send(sender=EmailAddress, email_address=email)
            Msg.add_message (request, Msg.SUCCESS, _('email address added'))
            form = EmailAddressForm(user=request.user)
    else:
        form = EmailAddressForm(user=request.user)
    emails_list = EmailAddress.objects.filter(user=request.user).order_by(*sort_email())
    return render_to_response(get_template('emailmgr_email_list.html'),
                              {
                                'email_list': emails_list,
                                'email_form': form
                              },
                              context_instance=RequestContext(request)
                              )
Exemplo n.º 21
0
                    required=False,
                    default='./template.tex')
parser.add_argument('-r',
                    '--renderfile',
                    help='Save Render to File',
                    required=False,
                    default='./rendered_latex.tex')
parser.add_argument('--verbose', help='Print more data', action='store_true')
args = vars(parser.parse_args())

project = "./"
in_file = args['input']
build_d = "{}.build/".format(project)
template_file = args['template']
out_file = "{}renderer_template.pdf".format(project)

#print("options = {}").format(options)
#TODO re-enable other data formats using arg parse switch https://stackoverflow.com/questions/17909294/python-argparse-mutual-exclusive-group

template = utils.get_template(template_file)

if args['type'] == "json":
    options = utils.get_json_options_recursively(in_file,
                                                 verbose=args["verbose"])
elif args['type'] == "options":
    options = utils.get_options_from_file(in_file)
else:  # args['type'] == "tex":
    options = dict()
if args["verbose"]: print(options)
utils.compile_pdf_from_template(template, options, out_file)
Exemplo n.º 22
0
 def get(self):
     template_name = 'bookmarks.jinja'
     t = utils.get_template(template_name)
     htmlstr = t.render()
     self.write(htmlstr)
Exemplo n.º 23
0
import utils

nested_product_list = ["first item", "second item", "third item", "detektor"]

template = utils.get_template("./example2_template.tex")
print(template)
variable_dict = {"products": nested_product_list}
utils.compile_pdf_from_template(template, variable_dict, "./ex1.pdf")
Exemplo n.º 24
0
 def _get_template(self, platform, prefix_dir):
     template = get_template(self._get_template_filename(platform))
     context = {
         'prefix': prefix_dir,
     }
     return template.substitute(**context)
Exemplo n.º 25
0
Arquivo: app.py Projeto: westurner/pbm
 def get(self):
     t = utils.get_template(self.template_path)
     htmlstr = t.render({
         'bookmarks': self.cb,
         'bookmarks_iter': iter(self.cb)})
     self.write(htmlstr)
Exemplo n.º 26
0
def register(request):
	form = forms.RegistrationForm()
	return render_to_response(get_template("index.html"), {"form": form})
Exemplo n.º 27
0
def login(request):
	from django.contrib.auth.views import login
	return login(request, get_template("index.html"))
Exemplo n.º 28
0
Arquivo: app.py Projeto: westurner/pbm
 def get(self):
   t = utils.get_template(self.template_path)
   htmlstr = t.render()
   self.write(htmlstr)
Exemplo n.º 29
0
import pandas as pd
import utils

product_data = pd.read_excel('./test_data.xls', index_col='Index')

categories = product_data['Category'].unique()

nested_product_list = {k:product_data[product_data['Category']==k].T.to_dict() for k in categories}

template = utils.get_template('./example1_template.tex')
variable_dict = {'products': nested_product_list}
utils.compile_pdf_from_template(template, variable_dict, './ex1.pdf')
Exemplo n.º 30
0
import argparse
import utils


parser = argparse.ArgumentParser(description='Render a LaTex Template with variables.')

parser.add_argument('-i','--in', help='Input File', required=False, default='./example.txt' )
parser.add_argument('-t','--template', help='Template File', required=False, default='./template.tex')
args = vars(parser.parse_args())


project = "./"
in_file = args['in']
build_d = "{}.build/".format(project)
template_file = args['template']
out_file = "{}renderer_template.pdf".format(project)

options = utils.get_options_from_file(in_file)

template = utils.get_template(template_file)

utils.compile_pdf_from_template(template, options, out_file)

renderer_template = template.render(**options)
Exemplo n.º 31
0
def new_app(app_name, app_dir):
    app_template = utils.get_template("supervisor.conf")
    app_conf = app_template.render({"app_name": app_name, "app_dir": app_dir})
    dest_config = "%s/%s.conf" % (config.SUPERVISOR_DIR, app_name)
    utils.write_config(dest_config, app_conf)