Skip to content

Commit

Permalink
Merge pull request #511 from networktocode/develop
Browse files Browse the repository at this point in the history
Merge develop branch into main - 1.8.1
  • Loading branch information
jeffkala authored Apr 19, 2024
2 parents f6a1500 + 3b1004e commit b1bdf00
Show file tree
Hide file tree
Showing 58 changed files with 1,386 additions and 1,050 deletions.
1 change: 1 addition & 0 deletions development_scripts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Developer script to generate markdown tables."""

from jinja2 import Environment, BaseLoader, select_autoescape
from netutils.utils import _JINJA2_FUNCTION_MAPPINGS
from netutils import lib_mapper
Expand Down
6 changes: 6 additions & 0 deletions docs/admin/release_notes/version_1.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@

- [#496](https://github.com/networktocode/netutils/pull/496) Fixed vyos lib_mapper.
- [#416](https://github.com/networktocode/netutils/pull/416) Fixed for `\n` characters in parsing bug in palo parser.

## [v1.8.1] 2024-04

### Fixed
- [#509](https://github.com/networktocode/netutils/pull/509) Fixed parsing of empty banner, and dual banner for Cisco platforms.

1 change: 1 addition & 0 deletions flat_postprocess/oui_postprocess.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Python code used to postprocess Flat github action data related to OUI mappings."""

import sys
import re
from urllib.request import urlopen
Expand Down
1 change: 1 addition & 0 deletions flat_postprocess/protocol_number_postprocess.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Python code used to postprocess Flat github action data related to Protocol mappings."""

import csv
import os
import sys
Expand Down
1 change: 1 addition & 0 deletions flat_postprocess/protocol_postprocess.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Python code used to postprocess Flat github action data related to Protocol mappings."""

import csv
import os
import sys
Expand Down
1 change: 0 additions & 1 deletion netutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Initialization file for library."""


from importlib import metadata


Expand Down
1 change: 1 addition & 0 deletions netutils/bandwidth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for performing bandwidth calculations."""

import re
import typing as t

Expand Down
1 change: 1 addition & 0 deletions netutils/banner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for working with the banner configuration."""

import re

from netutils.constants import CARET_C
Expand Down
1 change: 1 addition & 0 deletions netutils/config/clean.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for working with configuration to clean the config."""

# pylint: disable=anomalous-backslash-in-string

import re
Expand Down
8 changes: 5 additions & 3 deletions netutils/config/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ def paloalto_panos_clean_newlines(cfg: str) -> str:
)

newlines_cleaned_cfg = paloalto_panos_newline_regex.sub(
lambda match: match.group().replace("\n", " ")
if not any(substring in match.group() for substring in paloalto_panos_no_newline_cleanup_match)
else match.group(),
lambda match: (
match.group().replace("\n", " ")
if not any(substring in match.group() for substring in paloalto_panos_no_newline_cleanup_match)
else match.group()
),
cfg,
)

Expand Down
9 changes: 9 additions & 0 deletions netutils/config/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Parsers for different network operating systems."""

# pylint: disable=no-member,super-with-arguments,invalid-overridden-method,raise-missing-from,invalid-overridden-method,inconsistent-return-statements,super-with-arguments,redefined-argument-from-local,no-else-break,useless-super-delegation,too-many-lines

import re
Expand Down Expand Up @@ -95,6 +96,8 @@ def is_banner_start(self, line: str) -> bool:
True if line starts banner, else False.
"""
for banner_start in self.banner_start:
if not line:
return False
if line.lstrip().startswith(banner_start):
return True
return False
Expand Down Expand Up @@ -330,6 +333,9 @@ def build_config_relationship(self) -> t.List[ConfigLine]:
break
elif self.is_banner_start(line):
line = self._build_banner(line) # type: ignore
# line can potentially be another banner start therefore we do a secondary check.
if self.is_banner_start(line):
line = self._build_banner(line) # type: ignore

self._update_config_lines(line)
return self.config_lines
Expand Down Expand Up @@ -551,6 +557,9 @@ def _build_banner(self, config_line: str) -> t.Optional[str]:
def is_banner_one_line(config_line: str) -> bool:
"""Determine if all banner config is on one line."""
_, delimeter, banner = config_line.partition("^C")
# if the banner is the delimeter is a single line empty banner. e.g banner motd ^C^C which ios allows.
if banner == "^C":
return True
# Based on NXOS configs, the banner delimeter is ignored until another char is used
banner_config_start = banner.lstrip(delimeter)
if delimeter not in banner_config_start:
Expand Down
1 change: 1 addition & 0 deletions netutils/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constant definitions used in project."""

from netutils.data_files.protocol_mappings import ( # noqa: F401 # pylint:disable=unused-import
PROTOCOLS,
)
Expand Down
Loading

0 comments on commit b1bdf00

Please sign in to comment.