Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #132 from napalm-automation/develop
Browse files Browse the repository at this point in the history
0.1.0
  • Loading branch information
dbarrosop authored May 12, 2018
2 parents b14946b + 3d4e600 commit 1b7236b
Show file tree
Hide file tree
Showing 1,823 changed files with 1,775,681 additions and 548,180 deletions.
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is an example .flake8 config, used when developing *Black* itself.
# Keep in sync with setup.cfg which is used for source packages.

[flake8]
ignore = E266, E501, W503
max-line-length = 80
max-complexity = 15
select = B,C,E,F,W,T4,B9
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
.pytest_cache/

.ipynb_checkpoints

Expand Down
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
language: python
python:
- 2.7
# - 3.4
# - 3.5
- 3.6

matrix:
include:
- python: 3.6
env: TOXENV=sphinx
- python: 3.6
env: TOXENV=black
- python: 3.6
env: TOXENV=pylama
install:
# - pip install tox-travis
- pip install tox-travis
- pip install coveralls
- pip install -r requirements-dev.txt
deploy:
provider: pypi
user: dbarroso
Expand All @@ -16,7 +23,7 @@ deploy:
tags: true
branch: master
script:
- py.test
- tox test/
after_success:
- coveralls
- if [ $travis_tag ]; then curl -x post https://readthedocs.org/build/napalm; fi
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PYBINDPLUGIN=$(shell /usr/bin/env python -c 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)')
PYBINDPLUGIN=$(shell /usr/bin/env python -c 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')

MODELS_PATH=napalm_yang/models

YANG_OC=yang_oc/release/models
YANG_IETF=yang_ietf/standard/ietf
YANG_NAPALM=yang_napalm

PYANGBING=pyang --plugindir $(PYBINDPLUGIN) -f pybind
PYANGBIND=pyang --plugindir $(PYBINDPLUGIN) -f pybind --lax-quote-checks


clean:
Expand All @@ -22,19 +22,20 @@ openconfig_tree:
.PHONY: models_openconfig
models_openconfig:
rm -rf $(MODELS_PATH)/openconfig/
$(PYANGBING) \
$(PYANGBIND) \
--path $(YANG_OC) \
--split-class-dir=$(MODELS_PATH)/openconfig/ \
$(YANG_OC)/network-instance/openconfig-network-instance.yang \
$(YANG_OC)/interfaces/*.yang \
$(YANG_OC)/platform/*.yang \
$(YANG_OC)/vlan/*.yang \
$(YANG_OC)/system/*.yang \
$(YANG_NAPALM)/interfaces/*.yang

# .PHONY: models_ietf
# models_ietf:
# rm -rf $(MODELS_PATH)/ietf/
# $(PYANGBING) \
# $(PYANGBIND) \
# --path $(YANG_IETF)/RFC \
# --path $(YANG_IETF)/DRAFT \
# --split-class-dir=$(MODELS_PATH)/ietf/ \
Expand All @@ -55,3 +56,22 @@ templates:
.PHONY: tests
tests:
py.test

.PHONY: test_black
test_black:
find . \
-not -path "./.tox*" \
-not -path "./napalm_yang/models*" \
-not -path "./napalm_yang/mappings*" \
-not -path "./yang_ietf*" \
-not -path "./yang_oc*" \
-name "*.py" \
-exec black --check {} \+

.PHONY: test_sphinx
test_sphinx:
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html

.PHONY: test_pylama
test_pylama:
pylama .
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![PyPI](https://img.shields.io/pypi/v/napalm-yang.svg)](https://pypi.python.org/pypi/napalm-yang) [![PyPI](https://img.shields.io/pypi/dm/napalm-yang.svg)](https://pypi.python.org/pypi/napalm-yang) [![Build Status](https://travis-ci.org/napalm-automation/napalm-yang.svg?branch=master)](https://travis-ci.org/napalm-automation/napalm-yang) [![Coverage Status](https://coveralls.io/repos/github/napalm-automation/napalm-yang/badge.svg?branch=develop)](https://coveralls.io/github/napalm-automation/napalm-yang?branch=develop)
[![PyPI](https://img.shields.io/pypi/v/napalm-yang.svg)](https://pypi.python.org/pypi/napalm-yang) [![Build Status](https://travis-ci.org/napalm-automation/napalm-yang.svg?branch=master)](https://travis-ci.org/napalm-automation/napalm-yang) [![Coverage Status](https://coveralls.io/repos/github/napalm-automation/napalm-yang/badge.svg?branch=develop)](https://coveralls.io/github/napalm-automation/napalm-yang?branch=develop) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

napalm-yang
===========

Visit [RTD](https://napalm.readthedocs.io/en/latest/yang.html) for the documentation.
Visit [RTD](https://napalm-yang.readthedocs.io/en/latest/) for the documentation.
62 changes: 62 additions & 0 deletions docs/_dynamic/examples_leaf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. _examples_leaf:

Examples - leaf
===============

{% for e in examples %}
{{ e.example.documentation.title }}
{{ "-" * e.example.documentation.title|length }}

{{ e.example.documentation.summary }}

Original data
_____________

.. code::

{{ e.mocked|indent }}

{{ e.example.documentation.data|default("") }}

Parser rule
___________

.. code-block:: yaml

{{ e.example.rule|to_yaml|indent }}

{{ e.example.documentation.rule|default("") }}

Result
______

{{ e.example.documentation.result|default("") }}

{% for case in e.example.data %}

Example {{loop.index}}
^^^^^^^^^^

.. code-block:: yaml

{{ case|to_yaml|indent }}

.. raw:: html

<div><table border="1" class="docutils">
<tr>
<th class="head">block</th>
<th class="head">value</th>
</tr>
<tbody>
{% for r in e.example.expected[loop.index0] %}
<tr>
<td style="vertical-align: top;">{{ e.example.blocks[loop.index0]|escape }}</pre></td>
<td style="vertical-align: top;">{{ r }}</pre></td>
</tr>
{% endfor %}
</tbody>
</table></div>

{% endfor %}
{% endfor %}
14 changes: 12 additions & 2 deletions docs/_dynamic/parser_directives.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@
On <b>lists</b> regexp will be applied over the key. Use it to filter results and capture extra data.</br>
On <b>leaves</b>, regexp will assign as value the capture group <code class="docutils literal">value</code>
- name: value
- name: pre
available_on: leaf
description: |
Post processing/formatting of the value
Pre processing/formatting of the value. Useful when you want to statically set it based on ``when`` conditions or from values extracted previously in parent containers/leaves/lists.
- name: post
available_on: leaf
description: |
Post processing/formatting of the value. Useful when you need to combine data extracted in a regular expression or post-process it with a jinja2 filter to transform the value.
- name: map
available_on: leaf
Expand All @@ -59,3 +64,8 @@
description: |
This attribute is specific to the XMLParser. XML documents can add information in the form of attributes.
You can complement a <code class="docutils literal">path</code> with this field to extract the attribute from the element found in <code class="docutils literal">path</code>.
- name: pdb
abialble_on: list, container, leaf
description: |
Start ``pdb`` for debugging.
Binary file added docs/_static/napalm-yang.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 28 additions & 30 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,37 @@
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

autoclass_content = 'both'
autoclass_content = "both"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'napalm-yang'
copyright = u'2017, David Barroso'
project = u"napalm-yang"
copyright = u"2017, David Barroso"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0'
version = "0"
# The full version, including alpha/beta/rc tags.
release = '1'
release = "1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -72,7 +69,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -90,7 +87,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -103,14 +100,15 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
on_rtd = os.environ.get("READTHEDOCS", None) == "True"

if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
else:
html_theme = 'default'
html_theme = "default"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down Expand Up @@ -139,7 +137,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -188,18 +186,16 @@
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'napalmdoc'
htmlhelp_basename = "napalmdoc"


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}
Expand All @@ -208,8 +204,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'napalm.tex', u'NAPALM Documentation',
u'David Barroso', 'manual'),
("index", "napalm.tex", u"NAPALM Documentation", u"David Barroso", "manual")
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -237,10 +232,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'napalm', u'NAPALM Documentation',
[u'David Barroso'], 1)
]
man_pages = [("index", "napalm", u"NAPALM Documentation", [u"David Barroso"], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -252,9 +244,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'napalm-yang', u'NAPALM YANG Documentation',
u'David Barroso', 'napalm-yang', 'YANG framework for any device',
'Miscellaneous'),
(
"index",
"napalm-yang",
u"NAPALM YANG Documentation",
u"David Barroso",
"napalm-yang",
"YANG framework for any device",
"Miscellaneous",
)
]

# Documents to append as an appendix to all manuals.
Expand Down
1 change: 0 additions & 1 deletion docs/developers/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ WIP. Information here is a bit chaotic, sorry about that.
:maxdepth: 1

profiles
profiles/index
writing_profiles
parsers/index
translators
Expand Down
7 changes: 6 additions & 1 deletion docs/developers/parsers/dynamic_directives.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@
<td style="vertical-align: top;"> list, leaf</td>
<td style="vertical-align: top;"> On <b>lists</b> regexp will be applied over the key. Use it to filter results and capture extra data.</br>
On <b>leaves</b>, regexp will assign as value the capture group <code class="docutils literal">value</code></td>
</tr>
<tr>
<th style="vertical-align: top;"> pre</th>
<td style="vertical-align: top;"> leaf</td>
<td style="vertical-align: top;"> Pre processing/formatting of the value. Useful when you want to statically set it based on ``when`` conditions or from values extracted previously in parent containers/leaves/lists.</td>
</tr>
<tr>
<th style="vertical-align: top;"> value</th>
<td style="vertical-align: top;"> leaf</td>
<td style="vertical-align: top;"> Post processing/formatting of the value</td>
<td style="vertical-align: top;"> Post processing/formatting of the value. Useful when you need to combine data extracted in a regular expression or post-process it with a jinja2 filter to transform the value.</td>
</tr>
<tr>
<th style="vertical-align: top;"> map</th>
Expand Down
Loading

0 comments on commit 1b7236b

Please sign in to comment.