Skip to content

Commit

Permalink
Prepare Release (#13)
Browse files Browse the repository at this point in the history
prepare release
  • Loading branch information
carlmontanari authored Jul 30, 2021
1 parent ff4c670 commit b75b68c
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
max-parallel: 12
matrix:
os: [ubuntu-latest, macos-latest]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.1]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.4]
steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/weekly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
max-parallel: 12
matrix:
os: [ubuntu-latest, macos-latest]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.1]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.4]
steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.version }}
Expand Down
8 changes: 4 additions & 4 deletions docs/api_docs/diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class ScrapliCfgDiffResponse(ScrapliCfgResponse):

side_by_side_diff_lines = []
for line in self._difflines:
if line[:2] == " ?":
if line[:2] == "? ":
current = (
yellow + f"{line[2:][:diff_side_width].rstrip() : <{half_term_width}}" + end
)
Expand Down Expand Up @@ -204,7 +204,7 @@ class ScrapliCfgDiffResponse(ScrapliCfgResponse):

unified_diff = [
yellow + line[2:] + end
if line[:2] == " ?"
if line[:2] == "? "
else red + line[2:] + end
if line[:2] == "- "
else green + line[2:] + end
Expand Down Expand Up @@ -369,7 +369,7 @@ class ScrapliCfgDiffResponse(ScrapliCfgResponse):

side_by_side_diff_lines = []
for line in self._difflines:
if line[:2] == " ?":
if line[:2] == "? ":
current = (
yellow + f"{line[2:][:diff_side_width].rstrip() : <{half_term_width}}" + end
)
Expand Down Expand Up @@ -414,7 +414,7 @@ class ScrapliCfgDiffResponse(ScrapliCfgResponse):

unified_diff = [
yellow + line[2:] + end
if line[:2] == " ?"
if line[:2] == "? "
else red + line[2:] + end
if line[:2] == "- "
else green + line[2:] + end
Expand Down
28 changes: 24 additions & 4 deletions docs/api_docs/factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,19 @@ def ScrapliCfg(
ScrapliCfg: sync scrapli cfg object

Raises:
ScrapliCfgException: if platform is not a string
ScrapliCfgException: if provided connection object is async
ScrapliCfgException: if provided connection object is sync but is not a supported ("core")
platform type

"""
logger.debug("ScrapliCfg factory initialized")

if isinstance(conn, AsyncNetworkDriver):
raise ScrapliCfgException(
"provided scrapli connection is sync but using 'AsyncScrapliCfg' -- you must use an "
"async connection with 'AsyncScrapliCfg'!"
)

platform_class = SYNC_CORE_PLATFORM_MAP.get(type(conn))
if not platform_class:
raise ScrapliCfgException(
Expand Down Expand Up @@ -173,11 +181,19 @@ def AsyncScrapliCfg(
AsyncScrapliCfg: async scrapli cfg object

Raises:
ScrapliCfgException: if platform is not a string
ScrapliCfgException: if provided connection object is sync
ScrapliCfgException: if provided connection object is async but is not a supported ("core")
platform type

"""
logger.debug("AsyncScrapliCfg factory initialized")

if isinstance(conn, NetworkDriver):
raise ScrapliCfgException(
"provided scrapli connection is sync but using 'AsyncScrapliCfg' -- you must use an "
"async connection with 'AsyncScrapliCfg'!"
)

platform_class = ASYNC_CORE_PLATFORM_MAP.get(type(conn))
if not platform_class:
raise ScrapliCfgException(
Expand Down Expand Up @@ -237,7 +253,9 @@ Returns:
AsyncScrapliCfg: async scrapli cfg object
Raises:
ScrapliCfgException: if platform is not a string
ScrapliCfgException: if provided connection object is sync
ScrapliCfgException: if provided connection object is async but is not a supported ("core")
platform type
```


Expand Down Expand Up @@ -278,5 +296,7 @@ Returns:
ScrapliCfg: sync scrapli cfg object
Raises:
ScrapliCfgException: if platform is not a string
ScrapliCfgException: if provided connection object is async
ScrapliCfgException: if provided connection object is sync but is not a supported ("core")
platform type
```
4 changes: 4 additions & 0 deletions docs/api_docs/platform/base/async_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ class AsyncScrapliCfgPlatform(ABC, ScrapliCfgBase):
self.logger.debug("on_prepare provided, executing now")
await self.on_prepare(self)

self._prepared = True

async def cleanup(self) -> None:
"""
Cleanup after scrapli-cfg operations
Expand Down Expand Up @@ -575,6 +577,8 @@ class AsyncScrapliCfgPlatform(ABC, ScrapliCfgBase):
self.logger.debug("on_prepare provided, executing now")
await self.on_prepare(self)

self._prepared = True

async def cleanup(self) -> None:
"""
Cleanup after scrapli-cfg operations
Expand Down
4 changes: 4 additions & 0 deletions docs/api_docs/platform/base/sync_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ class ScrapliCfgPlatform(ABC, ScrapliCfgBase):
self.logger.debug("on_prepare provided, executing now")
self.on_prepare(self)

self._prepared = True

def cleanup(self) -> None:
"""
Cleanup after scrapli-cfg operations
Expand Down Expand Up @@ -574,6 +576,8 @@ class ScrapliCfgPlatform(ABC, ScrapliCfgBase):
self.logger.debug("on_prepare provided, executing now")
self.on_prepare(self)

self._prepared = True

def cleanup(self) -> None:
"""
Cleanup after scrapli-cfg operations
Expand Down
5 changes: 4 additions & 1 deletion docs/api_docs/platform/core/juniper_junos/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ scrapli_cfg.platform.core.juniper_junos.patterns
import re

VERSION_PATTERN = re.compile(
pattern=r"\d+\.\w+\.\w+",
# should match at least versions looking like:
# 17.3R2.10
# 18.1R3-S2.5
pattern=r"\d+\.[\w-]+\.\w+",
)
OUTPUT_HEADER_PATTERN = re.compile(pattern=r"^## last commit.*$\nversion.*$", flags=re.M | re.I)
EDIT_PATTERN = re.compile(pattern=r"^\[edit\]$", flags=re.M)
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Changelog
=========

## (in development) 2021.07.30
## 2021.07.30

- Initial release!
8 changes: 4 additions & 4 deletions examples/basic_usage/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version 16.12
service timestamps debug datetime msec
service timestamps log datetime msec
! Call-home is enabled by Smart-Licensing.
service call-home
platform qfp utilization monitor load 80
platform punt-keepalive disable-kernel-core
Expand All @@ -12,8 +13,7 @@ boot-start-marker
boot-end-marker
!
!
no logging monitor
enable secret 9 $9$h6Ayg86tb/EImk$2T6Ns.ke08cAlZ2TbMf3YRCYr7ngDGzgAxZB0YMe7lQ
enable secret 9 $9$xvWnx8Fe35f8xE$E9ijp7GM/V48P5y1Uz3IEPtotXgwkJKYJmN0q3q2E92
!
no aaa new-model
call-home
Expand Down Expand Up @@ -147,7 +147,7 @@ memory free low-watermark processor 72329
!
spanning-tree extend system-id
!
username vrnetlab privilege 15 password 0 VR-netlab9
username boxen privilege 15 pass 0 b0x3N-b0x3N
!
redundancy
!
Expand Down Expand Up @@ -255,7 +255,7 @@ no ip http server
no ip http secure-server
!
ip ssh pubkey-chain
username vrnetlab
username boxen
key-hash ssh-rsa 5CC74A68B18B026A1709FB09D1F44E2F
ip scp server enable
!
Expand Down
7 changes: 4 additions & 3 deletions examples/basic_usage/config_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from scrapli_cfg import ScrapliCfg

DEVICE = {
"host": "172.18.0.11",
"auth_username": "vrnetlab",
"auth_password": "VR-netlab9",
"host": "localhost",
"port": 21022,
"auth_username": "boxen",
"auth_password": "b0x3N-b0x3N",
"auth_strict_key": False,
"platform": "cisco_iosxe",
}
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
site_name: Scrapli Cfg
site_description: Network device configuration management with scrapli
site_author: Carl Montanari
site_url: https://scrapli.github.io/

repo_name: scrapli/scrapli_cfg
repo_url: https://github.com/scrapli/scrapli_cfg
Expand Down
14 changes: 7 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
black==21.5b1
black==21.7b0
darglint==1.8.0
isort==5.8.0
mypy==0.812
nox==2020.12.31
isort==5.9.3
mypy==0.910
nox==2021.6.12
pycodestyle==2.7.0
pydocstyle==6.1.1
pyfakefs==4.4.0
pyfakefs==4.5.0
pylama==7.7.1
pylint==2.8.2
pylint==2.9.6
pytest-asyncio==0.15.1
pytest-cov==2.12.0
pytest-cov==2.12.1
pytest==6.2.4
scrapli-replay==2021.7.30a5
-r requirements-asyncssh.txt
Expand Down
4 changes: 2 additions & 2 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mdx-gh-links==0.2
mkdocs==1.1.2
mkdocs-material==7.1.5
mkdocs==1.2.2
mkdocs-material==7.2.1
mkdocs-material-extensions==1.0.1
pdoc3==0.9.2 ; sys_platform != "win32"
4 changes: 2 additions & 2 deletions scrapli_cfg/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def side_by_side_diff(self) -> str:

side_by_side_diff_lines = []
for line in self._difflines:
if line[:2] == " ?":
if line[:2] == "? ":
current = (
yellow + f"{line[2:][:diff_side_width].rstrip() : <{half_term_width}}" + end
)
Expand Down Expand Up @@ -174,7 +174,7 @@ def unified_diff(self) -> str:

unified_diff = [
yellow + line[2:] + end
if line[:2] == " ?"
if line[:2] == "? "
else red + line[2:] + end
if line[:2] == "- "
else green + line[2:] + end
Expand Down
20 changes: 18 additions & 2 deletions scrapli_cfg/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,19 @@ def ScrapliCfg(
ScrapliCfg: sync scrapli cfg object
Raises:
ScrapliCfgException: if platform is not a string
ScrapliCfgException: if provided connection object is async
ScrapliCfgException: if provided connection object is sync but is not a supported ("core")
platform type
"""
logger.debug("ScrapliCfg factory initialized")

if isinstance(conn, AsyncNetworkDriver):
raise ScrapliCfgException(
"provided scrapli connection is sync but using 'AsyncScrapliCfg' -- you must use an "
"async connection with 'AsyncScrapliCfg'!"
)

platform_class = SYNC_CORE_PLATFORM_MAP.get(type(conn))
if not platform_class:
raise ScrapliCfgException(
Expand Down Expand Up @@ -143,11 +151,19 @@ def AsyncScrapliCfg(
AsyncScrapliCfg: async scrapli cfg object
Raises:
ScrapliCfgException: if platform is not a string
ScrapliCfgException: if provided connection object is sync
ScrapliCfgException: if provided connection object is async but is not a supported ("core")
platform type
"""
logger.debug("AsyncScrapliCfg factory initialized")

if isinstance(conn, NetworkDriver):
raise ScrapliCfgException(
"provided scrapli connection is sync but using 'AsyncScrapliCfg' -- you must use an "
"async connection with 'AsyncScrapliCfg'!"
)

platform_class = ASYNC_CORE_PLATFORM_MAP.get(type(conn))
if not platform_class:
raise ScrapliCfgException(
Expand Down
2 changes: 2 additions & 0 deletions scrapli_cfg/platform/base/async_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ async def prepare(self) -> None:
self.logger.debug("on_prepare provided, executing now")
await self.on_prepare(self)

self._prepared = True

async def cleanup(self) -> None:
"""
Cleanup after scrapli-cfg operations
Expand Down
2 changes: 2 additions & 0 deletions scrapli_cfg/platform/base/sync_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def prepare(self) -> None:
self.logger.debug("on_prepare provided, executing now")
self.on_prepare(self)

self._prepared = True

def cleanup(self) -> None:
"""
Cleanup after scrapli-cfg operations
Expand Down
5 changes: 4 additions & 1 deletion scrapli_cfg/platform/core/juniper_junos/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import re

VERSION_PATTERN = re.compile(
pattern=r"\d+\.\w+\.\w+",
# should match at least versions looking like:
# 17.3R2.10
# 18.1R3-S2.5
pattern=r"\d+\.[\w-]+\.\w+",
)
OUTPUT_HEADER_PATTERN = re.compile(pattern=r"^## last commit.*$\nversion.*$", flags=re.M | re.I)
EDIT_PATTERN = re.compile(pattern=r"^\[edit\]$", flags=re.M)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import setuptools

__version__ = "2021.07.30a9"
__version__ = "2021.07.30"
__author__ = "Carl Montanari"

with open("README.md", "r", encoding="utf-8") as f:
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
description racecar
end"""

COLORIZED_SIDE_BY_SIDE_DIFF = "! !\n\x1b[91minterface loopback123 \x1b[0m\n ^^^ ^^^\n \x1b[92minterface loopback456\x1b[0m\n ^^^ ^^^\n\x1b[91m description tacocat \x1b[0m\n ^ ^ ^ ^ ^ ^\n \x1b[92m description racecar\x1b[0m\n ^ ^ ^ ^ ^ ^\n! !"
SIDE_BY_SIDE_DIFF = "! !\n- interface loopback123 \n ^^^ ^^^\n + interface loopback456\n ^^^ ^^^\n- description tacocat \n ^ ^ ^ ^ ^ ^\n + description racecar\n ^ ^ ^ ^ ^ ^\n! !"
COLORIZED_UNIFIED_DIFF = "!\n\x1b[91minterface loopback123\n\x1b[0m ^^^\n\x1b[92minterface loopback456\n\x1b[0m ^^^\n\x1b[91m description tacocat\n\x1b[0m ^ ^ ^\n\x1b[92m description racecar\n\x1b[0m ^ ^ ^\n!\n"
UNIFIED_DIFF = "!\n- interface loopback123\n ^^^\n+ interface loopback456\n ^^^\n- description tacocat\n ^ ^ ^\n+ description racecar\n ^ ^ ^\n!\n"
COLORIZED_SIDE_BY_SIDE_DIFF = "! !\n\x1b[91minterface loopback123 \x1b[0m\n\x1b[93m ^^^ \x1b[0m\x1b[93m ^^^\x1b[0m\n \x1b[92minterface loopback456\x1b[0m\n\x1b[93m ^^^ \x1b[0m\x1b[93m ^^^\x1b[0m\n\x1b[91m description tacocat \x1b[0m\n\x1b[93m ^ ^ ^ \x1b[0m\x1b[93m ^ ^ ^\x1b[0m\n \x1b[92m description racecar\x1b[0m\n\x1b[93m ^ ^ ^ \x1b[0m\x1b[93m ^ ^ ^\x1b[0m\n! !"
SIDE_BY_SIDE_DIFF = "! !\n- interface loopback123 \n? ^^^ ? ^^^\n + interface loopback456\n? ^^^ ? ^^^\n- description tacocat \n? ^ ^ ^ ? ^ ^ ^\n + description racecar\n? ^ ^ ^ ? ^ ^ ^\n! !"
COLORIZED_UNIFIED_DIFF = "!\n\x1b[91minterface loopback123\n\x1b[0m\x1b[93m ^^^\n\x1b[0m\x1b[92minterface loopback456\n\x1b[0m\x1b[93m ^^^\n\x1b[0m\x1b[91m description tacocat\n\x1b[0m\x1b[93m ^ ^ ^\n\x1b[0m\x1b[92m description racecar\n\x1b[0m\x1b[93m ^ ^ ^\n\x1b[0m!\n"
UNIFIED_DIFF = "!\n- interface loopback123\n? ^^^\n+ interface loopback456\n? ^^^\n- description tacocat\n? ^ ^ ^\n+ description racecar\n? ^ ^ ^\n!\n"


def test_record_diff_response(diff_obj):
Expand Down
5 changes: 0 additions & 5 deletions tests/unit/test_logging.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import logging
import sys
from pathlib import Path

import pytest

from scrapli_cfg.logging import ScrapliFileHandler, ScrapliFormatter, enable_basic_logging, logger


@pytest.mark.skipif(sys.version_info > (3, 9), reason="skipping pending pyfakefs 3.10 support")
def test_enable_basic_logging(fs):
assert Path("scrapli_cfg.log").is_file() is False
enable_basic_logging(file=True, level="debug")
Expand All @@ -25,7 +21,6 @@ def test_enable_basic_logging(fs):
del logger.handlers[1]


@pytest.mark.skipif(sys.version_info > (3, 9), reason="skipping pending pyfakefs 3.10 support")
def test_enable_basic_logging_no_buffer(fs):
assert Path("mylog.log").is_file() is False

Expand Down

0 comments on commit b75b68c

Please sign in to comment.