Exemplo n.º 1
0
    def run(self):
        """
        Parse headers from source.

        :return: List of created nodes
        :rtype: list[headers_block]
        """
        headers = {}
        try:
            headers = parse_headers(self.content)
        except InvalidHeaderException as e:
            settings.log.error(str(e))
            settings.internal.status = False

        settings.headers.visible = headers
        node = headers_block(headers, Text(self.render_headers(headers)))

        return [node]
Exemplo n.º 2
0
    def load_from_cli(self, arguments):
        """
        Loads settings from CLI arguments.

        :param arguments: Dictionary generated by docopt
        :type arguments: dict
        """
        self.config = arguments.get('--config', self.config)
        self.load_from_file()

        if arguments['--headers']:
            splitted_headers = arguments['--headers'].split(',')
            self.headers.hidden.update(parse_headers(splitted_headers))

        self.cache.enabled = arguments.get('-c') or self.cache.enabled
        self.debug = arguments.get('-d') or self.debug
        self.output = arguments.get('-o') or self.output
        self.file = arguments.get('<in>') or self.file
        self.url = arguments.get('--url') or self.url
        self.log.verbosity = int(arguments.get('-v')) or self.log.verbosity
        self.prototype = arguments.get('--prototype') or self.prototype