How to use the genshi.builder.tag.__getattr__ function in Genshi

To help you get started, we’ve selected a few Genshi 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 pinax / pinax / libs / external_libs / Creoleparser-0.5.0 / creoleparser / elements.py View on Github external
def _build(self,mo,element_store):
        body = mo.group(1).split(self.delimiter,1)
        src_mo = self.src_regexp.search(body[0])
        if not src_mo:
            return bldr.tag.span('Bad Image src')
        if sanitizer.is_safe_uri(src_mo.group(1)):
            link = src_mo.group(1)
        else:
            link = "unsafe_uri_detected"
        if len(body) == 1:
            alias = link
        else:
            alias = body[1].strip()
        return bldr.tag.__getattr__(self.tag)(src=link ,alt=alias)
github prologic / sahriswiki / sahriswiki / creoleparser / elements.py View on Github external
def emit(self,element_store, environ,link_type,body,url,the_class, alt=None):
        if alt is None:
            if link_type == 'url':
                alt = urlparse.urlsplit(url).path.split('/')[-1]
            else:
                alt = body.strip()
        return bldr.tag.__getattr__(self.tag)(src=url ,alt=alt, title=alt,
                                              #class_=the_class
github timonwong / OmniMarkupPreviewer / OmniMarkupLib / Renderers / libs / python2 / creoleparser / elements.py View on Github external
def emit(self,element_store, environ,link_type,body,url,the_class, alt=None):

        if self.disable_external and link_type == 'external':
            return bldr.tag.span('External images are disabled', class_='external_image')

        if alt is None:
            if link_type == 'external':
                alt = urlparse.urlsplit(url).path.split('/')[-1]
            else:
                alt = body.strip()

            
        return bldr.tag.__getattr__(self.tag)(src=url ,alt=alt, title=alt,
                                              #class_=the_class
github pinax / pinax / libs / external_libs / Creoleparser-0.5.0 / creoleparser / elements.py View on Github external
def _build(self,mo,element_store):
        if (not mo.group(1)) and (mo.group(3) in self.linking_protocols):
            return bldr.tag.__getattr__(self.tag)(self.alias(mo,element_store),
                                              href=self.href(mo))
        else:
            return self.href(mo)
github timonwong / OmniMarkupPreviewer / OmniMarkupLib / Renderers / libs / python2 / creoleparser / elements.py View on Github external
def _build(self,mo,element_store, environ):
        """Returns a genshi Element that has ``self.tag`` as the
        outermost tag.

        This methods if called exclusively by ``_process``

        :parameters:
          mo
            match object, usually the one returned by
            self.regexp.search(s) 
        """
        return bldr.tag.__getattr__(self.tag)(fragmentize(mo.group(1),
                                                          self.child_elements,
                                                          element_store, environ))
github prologic / sahriswiki / sahriswiki / creoleparser / elements.py View on Github external
def _build(self,mo,element_store, environ):
        """Returns a genshi Element that has ``self.tag`` as the
        outermost tag.

        This methods if called exclusively by ``_process``

        :parameters:
          mo
            match object, usually the one returned by
            self.regexp.search(s) 
        """
        return bldr.tag.__getattr__(self.tag)(fragmentize(mo.group(1),
                                                          self.child_elements,
                                                          element_store, environ))
github timonwong / OmniMarkupPreviewer / OmniMarkupLib / Renderers / libs / python2 / creoleparser / elements.py View on Github external
macro = AttrDict(name=macro_name,arg_string=arg_string,
                         body=body, isblock=isblock, parsed_body=parsed_body)
        
        try:
            value = func(macro,environ,*pos,**kw)
        except TypeError , detail:
            tag = isblock and 'pre' or 'code'
            e = str(detail)
            msg = re.sub(r"^\w*\(\) ", '', e)
            mo = re.match(r'(.+)(\d+)(.+)(\d+) given\)$',msg)
            if mo: #re.search(r'given\)$',msg):
                #mo = re.match(r'(.+)(\d+)(.+)(\d+)(.+)$',msg)
                msg = mo.group(1) + str(int(mo.group(2))-2) \
                      + re.sub('arguments?','argument(s)',mo.group(3)) \
                      + str(int(mo.group(4))-2) + ' given)'
            value = bldr.tag.__getattr__(tag)("Macro error: '%s' %s"% (macro_name, msg),class_='macro_error')
        except MacroError, detail:
            tag = isblock and 'pre' or 'code'
            value = bldr.tag.__getattr__(tag)("Error in macro '%s': %s"% (macro_name,str(detail.value)),class_='macro_error')
        except:
            value = bldr.tag.pre('Unexpected error during macro execution!\n'
                                 + traceback.format_exc(20) ,
                                 class_='macro_error')

        return value
github prologic / sahriswiki / sahriswiki / creoleparser / elements.py View on Github external
def _build(self,mo,element_store, environ):
        heading_tag = self.tags[len(mo.group(1))-1]
        return bldr.tag.__getattr__(heading_tag)(fragmentize(mo.group(2),
                                                          self.child_elements,
                                                          element_store, environ))
github pinax / pinax / libs / external_libs / Creoleparser-0.5.0 / creoleparser / elements.py View on Github external
def _build(self,mo,element_store):
        return bldr.tag.__getattr__(self.tag)()