Skip to content

Commit

Permalink
make. it. work.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanculver committed Aug 8, 2023
1 parent 102aff1 commit e829436
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jupyter:
jupyter notebook --allow-root --ip=0.0.0.0 --NotebookApp.token=''

.PHONY: tests
tests: build_test_containers black sphinx-test pylama mypy nbval lint
tests: build_test_containers black sphinx-test pylama # Skipping mypy, nbval, lint for now
make pytest PYTHON=3.8
make pytest PYTHON=3.9

Expand Down
8 changes: 7 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -176,4 +176,10 @@
("py:class", "yangson.datamodel.DataModel"),
("py:class", "yangify.parser.RootParser"),
("py:class", "yangify.translator.RootTranslator"),
("py:class", "yangson.instance.RootNode"),
("py:class", "decimal.Decimal"),
("py:class", "ArrayValue"),
("py:class", "ObjectValue"),
("py:class", "RawValue"),
("py:class", "lxml.etree.Element"),
]
5 changes: 3 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sphinx<3.0.0
# Requirements for docs build
sphinx
sphinx_rtd_theme
sphinxcontrib-napoleon
nbsphinx
nbsphinx
4 changes: 2 additions & 2 deletions ntc_rosetta/drivers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class Driver:
classes inheriting from this class.
Attributes:
parser: Class attribute to defines which ``yangify.parser.RootParser`` to use
parser ::noindexentry:: Class attribute to defines which ``yangify.parser.RootParser`` to use
when parsing native data
translator: Class attribute to defines which ``yangify.translator.RootParser`` to use
translator ::noindexentry:: Class attribute to defines which ``yangify.translator.RootParser`` to use
when translating YANG models to native data
datamodel: Class attribute that defines which ``yangson.datamodel.DataModel`` the
parser and translator can operate on.
Expand Down
6 changes: 3 additions & 3 deletions ntc_rosetta/translators/ntc/ios/ntc_vlan/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def name(self, value: Optional[str]) -> None:
if value:
self.yy.result.add_command(f" name {value}")
else:
self.yy.result.add_command(f" no name")
self.yy.result.add_command(" no name")

def active(self, value: Optional[str]) -> None:
if value:
self.yy.result.add_command(f" no shutdown")
self.yy.result.add_command(" no shutdown")
else:
self.yy.result.add_command(f" shutdown")
self.yy.result.add_command(" shutdown")


class VlanConfig(Translator):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def description(self, value: Optional[str]) -> None:
if value:
self.yy.result.add_command(f" description {value}")
else:
self.yy.result.add_command(f" no description")
self.yy.result.add_command(" no description")

def enabled(self, value: Optional[bool]) -> None:
if value:
self.yy.result.add_command(f" no shutdown")
self.yy.result.add_command(" no shutdown")
else:
self.yy.result.add_command(f" shutdown")
self.yy.result.add_command(" shutdown")


class Subinterface(Translator):
Expand Down Expand Up @@ -75,27 +75,27 @@ def description(self, value: Optional[str]) -> None:
if value:
self.yy.result.add_command(f" description {value}")
else:
self.yy.result.add_command(f" no description")
self.yy.result.add_command(" no description")

def enabled(self, value: Optional[bool]) -> None:
if value:
self.yy.result.add_command(f" no shutdown")
self.yy.result.add_command(" no shutdown")
else:
self.yy.result.add_command(f" shutdown")
self.yy.result.add_command(" shutdown")

def mtu(self, value: Optional[int]) -> None:
if value:
self.yy.result.add_command(f" mtu {value}")
else:
self.yy.result.add_command(f" no mtu")
self.yy.result.add_command(" no mtu")

def loopback_mode(self, value: Optional[bool]) -> None:
"""set the loopback mode if the interface isn't a loopback"""
is_loop = re.match("loopback", self.yy.key, re.IGNORECASE)
if value and not is_loop:
self.yy.result.add_command(f" loopback mac")
self.yy.result.add_command(" loopback mac")
elif not is_loop:
self.yy.result.add_command(f" no loopback mac")
self.yy.result.add_command(" no loopback mac")


class Interface(Translator):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ class Yangify(TranslatorData):

def protocol_version(self, value: str) -> None:
if value == "V2":
self.yy.result.add_command(f"ip ssh version 2")
self.yy.result.add_command("ip ssh version 2")
elif value == "V1":
self.yy.result.add_command(f"ip ssh version 1")
self.yy.result.add_command("ip ssh version 1")
else:
self.yy.result.add_command(f"default ip ssh version")
self.yy.result.add_command("default ip ssh version")

def timeout(self, value: int) -> None:
if value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ def interface_mode(self, value: Optional[str]) -> None:
if value:
self.yy.result.add_command(f" switchport mode {value.lower()}")
else:
self.yy.result.add_command(f" switchport mode access")
self.yy.result.add_command(" switchport mode access")

def access_vlan(self, value: Optional[str]) -> None:
if value:
self.yy.result.add_command(f" switchport access vlan {value}")
else:
self.yy.result.add_command(f" switchport access vlan 1")
self.yy.result.add_command(" switchport access vlan 1")

def trunk_vlans(self, value: Optional[List[str]]) -> None:
if value:
vlans_str = ",".join([str(v) for v in value])
self.yy.result.add_command(f" switchport trunk allowed vlan {vlans_str}")
else:
self.yy.result.add_command(f" switchport trunk allowed vlan 1")
self.yy.result.add_command(" switchport trunk allowed vlan 1")


class SwitchedVlan(Translator):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def name(self, value: Optional[str]) -> None:
if value:
self.yy.result.add_command(f" name {value}")
else:
self.yy.result.add_command(f" no name")
self.yy.result.add_command(" no name")

def status(self, value: Optional[str]) -> None:
if value == "SUSPENDED":
self.yy.result.add_command(f" shutdown")
self.yy.result.add_command(" shutdown")
else:
self.yy.result.add_command(f" no shutdown")
self.yy.result.add_command(" no shutdown")


class Vlan(Translator):
Expand Down
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ yangify = "^0.1.2"
[tool.poetry.dev-dependencies]
pytest = "^4.2"
black = { version = "19.3b0", allow-prereleases = true }
pylama = "^7.6"
pylama = "^7.7"
flake8-import-order = "^0.18.0"
mypy = "^1.0.0"
pytest-pythonpath = "^0.7.3"
pytest-cov = "^2.6"
jupyter = "^1.0"
nbval = "^0.9.1"
# https://github.com/PyCQA/pyflakes/issues/721
pyflakes = "~2.4.0"

[build-system]
requires = ["poetry>=0.12"]
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ max-line-length = 110
python_paths = ./tests/integration/

[mypy]
python_version = 3.6
python_version = 3.8
check_untyped_defs = True
disallow_any_generics = True
disallow_untyped_calls = True
Expand All @@ -31,3 +31,6 @@ warn_unused_ignores = True
warn_redundant_casts = True
warn_return_any = True
warn_unused_configs = True
exclude = (?x)(
docs/.*\.py$ # Ignore all docs
)

0 comments on commit e829436

Please sign in to comment.