def generate(password, obfuscator = 'obfusc1_php', agent = 'stegaref_php'):

    obfuscator_path = os.path.join(
        obfuscators_templates_folder_path,
        obfuscator +
        '.tpl')
    agent_path = os.path.join(agent_templates_folder_path, agent + '.tpl')

    for path in (obfuscator_path, agent_path):
        if not os.path.isfile(path):
            raise FatalException(messages.generic.file_s_not_found % path)

    obfuscator_template = Template(filename=obfuscator_path)

    try:
        agent = Template(
            open(
                agent_path,
                'r').read()).render(
            password=password)
    except Exception as e:
        raise FatalException(
            messages.generate.error_agent_template_s_s %
            (agent_path, str(e)))

    agent = agent.strip(os.linesep)

    try:
        obfuscated = obfuscator_template.render(agent=agent)
    except Exception as e:
        raise FatalException(
            messages.generate.error_obfuscator_template_s_s %
            (obfuscator_path, str(e)))

    return obfuscated
Example #2
0
 def render(self, cr, uid, id, object, reference, currency, amount, context=None, **kwargs):
     """ Renders the form template of the given acquirer as a mako template  """
     if not isinstance(id, (int, long)):
         id = id[0]
     this = self.browse(cr, uid, id)
     if context is None:
         context = {}
     try:
         i18n_kind = _(object._description)  # may fail to translate, but at least we try
         result = MakoTemplate(this.form_template).render_unicode(
             object=object,
             reference=reference,
             currency=currency,
             amount=amount,
             kind=i18n_kind,
             quote=quote,
             # context kw would clash with mako internals
             ctx=context,
             format_exceptions=True,
         )
         return result.strip()
     except Exception:
         _logger.exception(
             "failed to render mako template value for payment.acquirer %s: %r", this.name, this.form_template
         )
         return
Example #3
0
 def render(self,
            cr,
            uid,
            id,
            object,
            reference,
            currency,
            amount,
            context=None,
            **kwargs):
     """ Renders the form template of the given acquirer as a mako template  """
     if not isinstance(id, (int, long)):
         id = id[0]
     this = self.browse(cr, uid, id)
     if context is None:
         context = {}
     try:
         i18n_kind = _(object._description
                       )  # may fail to translate, but at least we try
         result = MakoTemplate(this.form_template).render_unicode(
             object=object,
             reference=reference,
             currency=currency,
             amount=amount,
             kind=i18n_kind,
             quote=quote,
             # context kw would clash with mako internals
             ctx=context,
             format_exceptions=True)
         return result.strip()
     except Exception:
         _logger.exception(
             "failed to render mako template value for payment.acquirer %s: %r",
             this.name, this.form_template)
         return
Example #4
0
def generate(password, obfuscator='obfusc1_php', agent='stegaref_php'):

    obfuscator_path = os.path.join(obfuscators_templates_folder_path,
                                   obfuscator + '.tpl')
    agent_path = os.path.join(agent_templates_folder_path, agent + '.tpl')

    for path in (obfuscator_path, agent_path):
        if not os.path.isfile(path):
            raise FatalException(messages.generic.file_s_not_found % path)

    obfuscator_template = Template(filename=obfuscator_path)

    try:
        agent = Template(open(agent_path,
                              'r').read()).render(password=password)
    except Exception as e:
        raise FatalException(messages.generate.error_agent_template_s_s %
                             (agent_path, str(e)))

    agent = agent.strip(os.linesep)

    try:
        obfuscated = obfuscator_template.render(agent=agent)
    except Exception as e:
        raise FatalException(messages.generate.error_obfuscator_template_s_s %
                             (obfuscator_path, str(e)))

    return obfuscated
Example #5
0
    def message_quote_context(self, cr, uid, id, context=None, limit=3, add_original=False):
        """
            1. message.parent_id = False: new thread, no quote_context
            2. get the lasts messages in the thread before message
            3. get the message header
            4. add an expandable between them

            :param dict quote_context: options for quoting
            :return string: html quote
        """
        add_expandable = False

        message = self.browse(cr, uid, id, context=context)
        if not message.parent_id:
            return ''
        context_ids = self.search(cr, uid, [
            ('parent_id', '=', message.parent_id.id),
            ('id', '<', message.id),
            ], limit=limit, context=context)

        if len(context_ids) >= limit:
            add_expandable = True
            context_ids = context_ids[0:-1]

        context_ids.append(message.parent_id.id)
        context_messages = self.browse(cr, uid, context_ids, context=context)
        header_message = context_messages.pop()

        try:
            if not add_original:
                message = False
            result = MakoTemplate(self.MAIL_TEMPLATE).render_unicode(message=message,
                                                        context_messages=context_messages,
                                                        header_message=header_message,
                                                        add_expandable=add_expandable,
                                                        # context kw would clash with mako internals
                                                        ctx=context,
                                                        format_exceptions=True)
            result = result.strip()
            return result
        except Exception:
            _logger.exception("failed to render mako template for quoting message")
            return ''
        return result
Example #6
0
    def message_quote_context(self, cr, uid, id, context=None, limit=3, add_original=False):
        """
            1. message.parent_id = False: new thread, no quote_context
            2. get the lasts messages in the thread before message
            3. get the message header
            4. add an expandable between them

            :param dict quote_context: options for quoting
            :return string: html quote
        """
        add_expandable = False

        message = self.browse(cr, uid, id, context=context)
        if not message.parent_id:
            return ''
        context_ids = self.search(cr, uid, [
            ('parent_id', '=', message.parent_id.id),
            ('id', '<', message.id),
            ], limit=limit, context=context)

        if len(context_ids) >= limit:
            add_expandable = True
            context_ids = context_ids[0:-1]

        context_ids.append(message.parent_id.id)
        context_messages = self.browse(cr, uid, context_ids, context=context)
        header_message = context_messages.pop()

        try:
            if not add_original:
                message = False
            result = MakoTemplate(self.MAIL_TEMPLATE).render_unicode(message=message,
                                                        context_messages=context_messages,
                                                        header_message=header_message,
                                                        add_expandable=add_expandable,
                                                        # context kw would clash with mako internals
                                                        ctx=context,
                                                        format_exceptions=True)
            result = result.strip()
            return result
        except Exception:
            _logger.exception("failed to render mako template for quoting message")
            return ''
        return result
Example #7
0
def tags(request):
    """Render tag page."""

    # Get awarded assertions.
    if authenticated_userid(request):
        awarded_assertions = request.db.get_assertions_by_email(
                                authenticated_userid(request))
    else:
        awarded_assertions = None

    # Get badges matching tag.
    tags = [t.strip() for t in request.matchdict.get('tags').split(',')]
    if request.matchdict.get('match') == 'all':
        badges = request.db.get_badges_from_tags(tags, match_all=True)
    else:
        badges = request.db.get_badges_from_tags(tags, match_all=False)

    return dict(
            tags=tags,
            badges=badges,
            auth_principals=effective_principals(request),
            awarded_assertions=awarded_assertions,
            )
Example #8
0
def tags(request):
    """Render tag page."""

    # Get awarded assertions.
    if authenticated_userid(request):
        awarded_assertions = request.db.get_assertions_by_email(
            authenticated_userid(request))
    else:
        awarded_assertions = None

    # Get badges matching tag.
    tags = [t.strip() for t in request.matchdict.get('tags').split(',')]
    if request.matchdict.get('match') == 'all':
        badges = request.db.get_badges_from_tags(tags, match_all=True)
    else:
        badges = request.db.get_badges_from_tags(tags, match_all=False)

    return dict(
        tags=tags,
        badges=badges,
        auth_principals=effective_principals(request),
        awarded_assertions=awarded_assertions,
    )
Example #9
0
1111    AnimatorTransitionBase
1112    SubstanceImporter
1113    LightmapParameters
1120    LightmapSnapshot
'''

from mako.template import Template

template = '''
static std::map<int, std::string> ClassIDToClassName {
% for p in Pairs:
	{ ${p[0]}, "${p[1]}" },
% endfor
};
'''
template = Template(template.strip())

template2 = '''
static std::map<std::string, int> ClassNameToClassID {
% for p in Pairs:
	{ "${p[1]}", ${p[0]} },
% endfor
};
'''
template2 = Template(template2.strip())

lines = s.strip().split('\n')
pairs = [line.split() for line in lines]
# print(pairs)
print(template.render(Pairs = pairs))
print("")