-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from networktocode/develop
v1.0.0 Release
- Loading branch information
Showing
19 changed files
with
402 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
******* | ||
Banner | ||
******* | ||
|
||
.. automodule:: netutils.banner | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ Netutils Functions | |
|
||
asn/index | ||
bandwidth/index | ||
banner/index | ||
configs/index | ||
dns/index | ||
interface/index | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Initialization file for library.""" | ||
|
||
__version__ = "0.2.5" | ||
__version__ = "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Functions for working with the banner configuration.""" | ||
import re | ||
from netutils.constants import CARET_C | ||
|
||
|
||
def delimiter_change(config, from_delimiter, to_delimiter): | ||
r"""Change the banner delimiter. | ||
Args: | ||
config (str): Configuration line containing banner delimiter. | ||
from_delimiter (str): Delimiter to replace in the banner. | ||
to_delimiter (str): Delimiter to include in the config. | ||
Returns: | ||
str: Configuration with delimiter replaced. | ||
Example: | ||
>>> from netutils.banner import delimiter_change | ||
>>> delimiter_change("banner login ^\n******************\n TEST BANNER\n******************^", "^", "^C") | ||
'banner login ^C\n******************\n TEST BANNER\n******************^C' | ||
>>> delimiter_change("banner login #\n******************\n TEST BANNER\n******************#", "#", "^C") | ||
'banner login ^C\n******************\n TEST BANNER\n******************^C' | ||
>>> delimiter_change("banner login ^CCCCC\n******************\n TEST BANNER\n******************^C", "^C", "^C") | ||
'banner login ^C\n******************\n TEST BANNER\n******************^C' | ||
""" | ||
config_line = config.replace(from_delimiter, to_delimiter) | ||
if to_delimiter == CARET_C: | ||
config_line = re.sub(r"\^C+", CARET_C, config_line) | ||
return config_line | ||
|
||
|
||
def normalise_delimiter_caret_c(delimiter, config): | ||
r"""Normalise delimiter to ^C. | ||
Args: | ||
delimiter (str): Banner delimiter. | ||
config (str): Configuration line containing banner delimiter. | ||
Returns: | ||
str: Configuration with delimiter normalised to ^C. | ||
Example: | ||
>>> from netutils.banner import normalise_delimiter_caret_c | ||
>>> normalise_delimiter_caret_c("^", "banner login ^\n******************\n TEST BANNER\n******************^") | ||
'banner login ^C\n******************\n TEST BANNER\n******************^C' | ||
>>> normalise_delimiter_caret_c("^C", "banner login ^CCCCC\n******************\n TEST BANNER\n******************^C") | ||
'banner login ^C\n******************\n TEST BANNER\n******************^C' | ||
""" | ||
config_line = delimiter_change(config, delimiter, CARET_C) | ||
return config_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.