src/license_expression/__init__.py
def render(self, template='{symbol.key}', *args, **kwargs):
        """
        Render an expression as a string, recursively applying the string
        ``template`` to every symbols and operators.
        """
        expression_args = self.args
        if len(expression_args) == 1:
            # a bare symbol
            sym = expression_args[0]
            if isinstance(sym, Renderable):
                sym = sym.render(template, *args, **kwargs)

            else:
                # FIXME: CAN THIS EVER HAPPEN since we only have symbols OR and AND?
                print(
                    'WARNING: symbol is not renderable: using plain string '
                    f'representation: {sym!r}'
                )
                sym = str(sym)

            # NB: the operator str already has a leading and trailing space
            if self.isliteral:
                rendered = f'{self.operator}{sym}'
            else:
                rendered = f'{self.operator}({sym})'
            return rendered

        rendered_items = []
        rendered_items_append = rendered_items.append
        for arg in expression_args:
            if isinstance(arg, Renderable):
                # recurse
                rendered = arg.render(template, *args, **kwargs)

            else:
                # FIXME: CAN THIS EVER HAPPEN since we only have symbols OR and AND?
                print(
                    'WARNING: object in expression is not renderable: '
                    f'falling back to plain string representation: {arg!r}.'
                )
                rendered = str(arg)

            if arg.isliteral:
                rendered_items_append(rendered)
            else:
                rendered_items_append(f'({rendered})')

        return self.operator.join(rendered_items)

        Render an expression as a string, recursively applying the string
        ``template`` to every symbols and operators.
        
Render an expression as a string, recursively applying the string
``template`` to every symbols and operators.
Render an expression as a string recursively applying the string ` ` template ` ` to every symbols and operators .
def render(self, template='{symbol.key}', *args, **kwargs):
        expression_args = self.args
        if len(expression_args) == 1:
            sym = expression_args[0]
            if isinstance(sym, Renderable):
                sym = sym.render(template, *args, **kwargs)
            else:
                print(
                    'WARNING: symbol is not renderable: using plain string '
                    f'representation: {sym!r}'
                )
                sym = str(sym)
            if self.isliteral:
                rendered = f'{self.operator}{sym}'
            else:
                rendered = f'{self.operator}({sym})'
            return rendered
        rendered_items = []
        rendered_items_append = rendered_items.append
        for arg in expression_args:
            if isinstance(arg, Renderable):
                rendered = arg.render(template, *args, **kwargs)
            else:
                print(
                    'WARNING: object in expression is not renderable: '
                    f'falling back to plain string representation: {arg!r}.'
                )
                rendered = str(arg)
            if arg.isliteral:
                rendered_items_append(rendered)
            else:
                rendered_items_append(f'({rendered})')
        return self.operator.join(rendered_items)
def render ( self , template = '{symbol.key}' , * args , ** kwargs ) : expression_args = self . args if len ( expression_args ) == 1 : sym = expression_args [ 0 ] if isinstance ( sym , Renderable ) : sym = sym . render ( template , * args , ** kwargs ) else : print ( 'WARNING: symbol is not renderable: using plain string ' f'representation: {sym!r}' ) sym = str ( sym ) if self . isliteral : rendered = f'{self.operator}{sym}' else : rendered = f'{self.operator}({sym})' return rendered rendered_items = [ ] rendered_items_append = rendered_items . append for arg in expression_args : if isinstance ( arg , Renderable ) : rendered = arg . render ( template , * args , ** kwargs ) else : print ( 'WARNING: object in expression is not renderable: ' f'falling back to plain string representation: {arg!r}.' ) rendered = str ( arg ) if arg . isliteral : rendered_items_append ( rendered ) else : rendered_items_append ( f'({rendered})' ) return self . operator . join ( rendered_items )
Render an expression as a string, recursively applying the string
``template`` to every symbols and operators.
Render an expression as a string recursively applying the string ` ` template ` ` to every symbols and operators .
"""
        Render an expression as a string, recursively applying the string
        ``template`` to every symbols and operators.
        """ # a bare symbol # FIXME: CAN THIS EVER HAPPEN since we only have symbols OR and AND? # NB: the operator str already has a leading and trailing space # recurse # FIXME: CAN THIS EVER HAPPEN since we only have symbols OR and AND?
self
template