Beispiel #1
0
    def clean_config(self, config: str) -> str:
        """
        Clean a configuration file of unwanted lines

        Args:
            config: configuration string to "clean"

        Returns:
            str: cleaned configuration string

        Raises:
            N/A

        """
        self.logger.debug("cleaning config file")

        config = re.sub(pattern=CHECKPOINT_LINE, string=config, repl="")
        config = re.sub(pattern=OUTPUT_HEADER_PATTERN, string=config, repl="")
        return strip_blank_lines(config=config)
Beispiel #2
0
    def clean_config(self, config: str) -> str:
        """
        Clean a configuration file of unwanted lines

        Args:
            config: configuration string to "clean"; cleaning removes lines that would prevent using
                the provided configuration as a "load_config" source from working -- i.e. removes
                the leading "Building Configuration" line

        Returns:
            str: cleaned configuration string

        Raises:
            N/A

        """
        self.logger.debug("cleaning config file")

        return strip_blank_lines(config=re.sub(
            pattern=OUTPUT_HEADER_PATTERN, string=config, repl=""))
Beispiel #3
0
    def clean_config(self, config: str) -> str:
        """
        Clean a configuration file of unwanted lines

        Args:
            config: configuration string to "clean"; cleaning removes leading timestamp/building
                config/xr version/last change lines.

        Returns:
            str: cleaned configuration string

        Raises:
            N/A

        """
        self.logger.debug("cleaning config file")

        # remove any of the leading timestamp/building config/xr version/last change lines in
        # both the source and candidate configs so they dont need to be compared
        return strip_blank_lines(config=re.sub(
            pattern=OUTPUT_HEADER_PATTERN, string=config, repl=""))
Beispiel #4
0
    def clean_config(self, config: str) -> str:
        """
        Clean a configuration file of unwanted lines

        Args:
            config: configuration string to "clean";  remove all comment lines from both the source
                and candidate configs -- this is only done here pre-diff, so we dont modify the user
                provided candidate config which can totally have those comment lines - we only
                remove "global" (top level) comments though... user comments attached to interfaces
                and the stuff will remain

        Returns:
            str: cleaned configuration string

        Raises:
            N/A

        """
        self.logger.debug("cleaning config file")

        return strip_blank_lines(config=re.sub(
            pattern=GLOBAL_COMMENT_LINE_PATTERN, string=config, repl=""))