Skip to content

Commit b1bdf00

Browse files
authored
Merge pull request #511 from networktocode/develop
Merge develop branch into main - 1.8.1
2 parents f6a1500 + 3b1004e commit b1bdf00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1386
-1050
lines changed

development_scripts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Developer script to generate markdown tables."""
2+
23
from jinja2 import Environment, BaseLoader, select_autoescape
34
from netutils.utils import _JINJA2_FUNCTION_MAPPINGS
45
from netutils import lib_mapper

docs/admin/release_notes/version_1.8.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@
2929

3030
- [#496](https://github.com/networktocode/netutils/pull/496) Fixed vyos lib_mapper.
3131
- [#416](https://github.com/networktocode/netutils/pull/416) Fixed for `\n` characters in parsing bug in palo parser.
32+
33+
## [v1.8.1] 2024-04
34+
35+
### Fixed
36+
- [#509](https://github.com/networktocode/netutils/pull/509) Fixed parsing of empty banner, and dual banner for Cisco platforms.
37+

flat_postprocess/oui_postprocess.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Python code used to postprocess Flat github action data related to OUI mappings."""
2+
23
import sys
34
import re
45
from urllib.request import urlopen

flat_postprocess/protocol_number_postprocess.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Python code used to postprocess Flat github action data related to Protocol mappings."""
2+
23
import csv
34
import os
45
import sys

flat_postprocess/protocol_postprocess.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Python code used to postprocess Flat github action data related to Protocol mappings."""
2+
23
import csv
34
import os
45
import sys

netutils/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Initialization file for library."""
22

3-
43
from importlib import metadata
54

65

netutils/bandwidth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions for performing bandwidth calculations."""
2+
23
import re
34
import typing as t
45

netutils/banner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions for working with the banner configuration."""
2+
23
import re
34

45
from netutils.constants import CARET_C

netutils/config/clean.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions for working with configuration to clean the config."""
2+
23
# pylint: disable=anomalous-backslash-in-string
34

45
import re

netutils/config/conversion.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ def paloalto_panos_clean_newlines(cfg: str) -> str:
114114
)
115115

116116
newlines_cleaned_cfg = paloalto_panos_newline_regex.sub(
117-
lambda match: match.group().replace("\n", " ")
118-
if not any(substring in match.group() for substring in paloalto_panos_no_newline_cleanup_match)
119-
else match.group(),
117+
lambda match: (
118+
match.group().replace("\n", " ")
119+
if not any(substring in match.group() for substring in paloalto_panos_no_newline_cleanup_match)
120+
else match.group()
121+
),
120122
cfg,
121123
)
122124

netutils/config/parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Parsers for different network operating systems."""
2+
23
# 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
34

45
import re
@@ -95,6 +96,8 @@ def is_banner_start(self, line: str) -> bool:
9596
True if line starts banner, else False.
9697
"""
9798
for banner_start in self.banner_start:
99+
if not line:
100+
return False
98101
if line.lstrip().startswith(banner_start):
99102
return True
100103
return False
@@ -330,6 +333,9 @@ def build_config_relationship(self) -> t.List[ConfigLine]:
330333
break
331334
elif self.is_banner_start(line):
332335
line = self._build_banner(line) # type: ignore
336+
# line can potentially be another banner start therefore we do a secondary check.
337+
if self.is_banner_start(line):
338+
line = self._build_banner(line) # type: ignore
333339

334340
self._update_config_lines(line)
335341
return self.config_lines
@@ -551,6 +557,9 @@ def _build_banner(self, config_line: str) -> t.Optional[str]:
551557
def is_banner_one_line(config_line: str) -> bool:
552558
"""Determine if all banner config is on one line."""
553559
_, delimeter, banner = config_line.partition("^C")
560+
# if the banner is the delimeter is a single line empty banner. e.g banner motd ^C^C which ios allows.
561+
if banner == "^C":
562+
return True
554563
# Based on NXOS configs, the banner delimeter is ignored until another char is used
555564
banner_config_start = banner.lstrip(delimeter)
556565
if delimeter not in banner_config_start:

netutils/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Constant definitions used in project."""
2+
23
from netutils.data_files.protocol_mappings import ( # noqa: F401 # pylint:disable=unused-import
34
PROTOCOLS,
45
)

0 commit comments

Comments
 (0)