How to use the certbot-nginx.certbot_nginx._internal.parser_obj.Block function in certbot-nginx

To help you get started, we’ve selected a few certbot-nginx 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 certbot / certbot / certbot-nginx / certbot_nginx / _internal / parser_obj.py View on Github external
def __init__(self, parent=None):
        super(Block, self).__init__(parent)
        self.names = None # type: Sentence
        self.contents = None # type: Block
github certbot / certbot / certbot-nginx / certbot_nginx / _internal / parser_obj.py View on Github external
def parse(self, raw_list, add_spaces=False):
        """ Parses a list that resembles a block.

        The assumptions that this routine makes are:
            1. the first element of `raw_list` is a valid Sentence.
            2. the second element of `raw_list` is a valid Statement.
        If add_spaces is set, we call it recursively on `names` and `contents`, and
        add an extra trailing space to `names` (to separate the block's opening bracket
        and the block name).
        """
        if not Block.should_parse(raw_list):
            raise errors.MisconfigurationError("Block parsing expects a list of length 2. "
                "First element should be a list of string types (the bloc names), "
                "and second should be another list of statements (the bloc content).")
        self.names = Sentence(self)
        if add_spaces:
            raw_list[0].append(" ")
        self.names.parse(raw_list[0], add_spaces)
        self.contents = Statements(self)
        self.contents.parse(raw_list[1], add_spaces)
        self._data = [self.names, self.contents]