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

Commit 1b7236b

Browse files
authored
Merge pull request #132 from napalm-automation/develop
0.1.0
2 parents b14946b + 3d4e600 commit 1b7236b

File tree

1,823 files changed

+1775681
-548180
lines changed

Some content is hidden

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

1,823 files changed

+1775681
-548180
lines changed

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This is an example .flake8 config, used when developing *Black* itself.
2+
# Keep in sync with setup.cfg which is used for source packages.
3+
4+
[flake8]
5+
ignore = E266, E501, W503
6+
max-line-length = 80
7+
max-complexity = 15
8+
select = B,C,E,F,W,T4,B9

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
33
*.py[cod]
4+
.pytest_cache/
45

56
.ipynb_checkpoints
67

.travis.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
language: python
22
python:
33
- 2.7
4-
# - 3.4
5-
# - 3.5
4+
- 3.6
5+
6+
matrix:
7+
include:
8+
- python: 3.6
9+
env: TOXENV=sphinx
10+
- python: 3.6
11+
env: TOXENV=black
12+
- python: 3.6
13+
env: TOXENV=pylama
614
install:
7-
# - pip install tox-travis
15+
- pip install tox-travis
816
- pip install coveralls
9-
- pip install -r requirements-dev.txt
1017
deploy:
1118
provider: pypi
1219
user: dbarroso
@@ -16,7 +23,7 @@ deploy:
1623
tags: true
1724
branch: master
1825
script:
19-
- py.test
26+
- tox test/
2027
after_success:
2128
- coveralls
2229
- if [ $travis_tag ]; then curl -x post https://readthedocs.org/build/napalm; fi

Makefile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
PYBINDPLUGIN=$(shell /usr/bin/env python -c 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)')
1+
PYBINDPLUGIN=$(shell /usr/bin/env python -c 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')
22

33
MODELS_PATH=napalm_yang/models
44

55
YANG_OC=yang_oc/release/models
66
YANG_IETF=yang_ietf/standard/ietf
77
YANG_NAPALM=yang_napalm
88

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

1111

1212
clean:
@@ -22,19 +22,20 @@ openconfig_tree:
2222
.PHONY: models_openconfig
2323
models_openconfig:
2424
rm -rf $(MODELS_PATH)/openconfig/
25-
$(PYANGBING) \
25+
$(PYANGBIND) \
2626
--path $(YANG_OC) \
2727
--split-class-dir=$(MODELS_PATH)/openconfig/ \
2828
$(YANG_OC)/network-instance/openconfig-network-instance.yang \
2929
$(YANG_OC)/interfaces/*.yang \
3030
$(YANG_OC)/platform/*.yang \
3131
$(YANG_OC)/vlan/*.yang \
32+
$(YANG_OC)/system/*.yang \
3233
$(YANG_NAPALM)/interfaces/*.yang
3334

3435
# .PHONY: models_ietf
3536
# models_ietf:
3637
# rm -rf $(MODELS_PATH)/ietf/
37-
# $(PYANGBING) \
38+
# $(PYANGBIND) \
3839
# --path $(YANG_IETF)/RFC \
3940
# --path $(YANG_IETF)/DRAFT \
4041
# --split-class-dir=$(MODELS_PATH)/ietf/ \
@@ -55,3 +56,22 @@ templates:
5556
.PHONY: tests
5657
tests:
5758
py.test
59+
60+
.PHONY: test_black
61+
test_black:
62+
find . \
63+
-not -path "./.tox*" \
64+
-not -path "./napalm_yang/models*" \
65+
-not -path "./napalm_yang/mappings*" \
66+
-not -path "./yang_ietf*" \
67+
-not -path "./yang_oc*" \
68+
-name "*.py" \
69+
-exec black --check {} \+
70+
71+
.PHONY: test_sphinx
72+
test_sphinx:
73+
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html
74+
75+
.PHONY: test_pylama
76+
test_pylama:
77+
pylama .

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[![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)
1+
[![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)
22

33
napalm-yang
44
===========
55

6-
Visit [RTD](https://napalm.readthedocs.io/en/latest/yang.html) for the documentation.
6+
Visit [RTD](https://napalm-yang.readthedocs.io/en/latest/) for the documentation.

docs/_dynamic/examples_leaf.j2

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _examples_leaf:
2+
3+
Examples - leaf
4+
===============
5+
6+
{% for e in examples %}
7+
{{ e.example.documentation.title }}
8+
{{ "-" * e.example.documentation.title|length }}
9+
10+
{{ e.example.documentation.summary }}
11+
12+
Original data
13+
_____________
14+
15+
.. code::
16+
17+
{{ e.mocked|indent }}
18+
19+
{{ e.example.documentation.data|default("") }}
20+
21+
Parser rule
22+
___________
23+
24+
.. code-block:: yaml
25+
26+
{{ e.example.rule|to_yaml|indent }}
27+
28+
{{ e.example.documentation.rule|default("") }}
29+
30+
Result
31+
______
32+
33+
{{ e.example.documentation.result|default("") }}
34+
35+
{% for case in e.example.data %}
36+
37+
Example {{loop.index}}
38+
^^^^^^^^^^
39+
40+
.. code-block:: yaml
41+
42+
{{ case|to_yaml|indent }}
43+
44+
.. raw:: html
45+
46+
<div><table border="1" class="docutils">
47+
<tr>
48+
<th class="head">block</th>
49+
<th class="head">value</th>
50+
</tr>
51+
<tbody>
52+
{% for r in e.example.expected[loop.index0] %}
53+
<tr>
54+
<td style="vertical-align: top;">{{ e.example.blocks[loop.index0]|escape }}</pre></td>
55+
<td style="vertical-align: top;">{{ r }}</pre></td>
56+
</tr>
57+
{% endfor %}
58+
</tbody>
59+
</table></div>
60+
61+
{% endfor %}
62+
{% endfor %}

docs/_dynamic/parser_directives.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@
3030
On <b>lists</b> regexp will be applied over the key. Use it to filter results and capture extra data.</br>
3131
On <b>leaves</b>, regexp will assign as value the capture group <code class="docutils literal">value</code>
3232
33-
- name: value
33+
- name: pre
3434
available_on: leaf
3535
description: |
36-
Post processing/formatting of the value
36+
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.
37+
38+
- name: post
39+
available_on: leaf
40+
description: |
41+
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.
3742
3843
- name: map
3944
available_on: leaf
@@ -59,3 +64,8 @@
5964
description: |
6065
This attribute is specific to the XMLParser. XML documents can add information in the form of attributes.
6166
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>.
67+
68+
- name: pdb
69+
abialble_on: list, container, leaf
70+
description: |
71+
Start ``pdb`` for debugging.

docs/_static/napalm-yang.png

1.72 MB
Loading

docs/conf.py

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,37 @@
2525
# If your documentation needs a minimal Sphinx version, state it here.
2626
# needs_sphinx = '1.0'
2727

28-
autoclass_content = 'both'
28+
autoclass_content = "both"
2929

3030
# Add any Sphinx extension module names here, as strings. They can be
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
33-
extensions = [
34-
'sphinx.ext.autodoc',
35-
'sphinx.ext.napoleon',
36-
]
33+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"]
3734

3835
# Add any paths that contain templates here, relative to this directory.
39-
templates_path = ['_templates']
36+
templates_path = ["_templates"]
4037

4138
# The suffix of source filenames.
42-
source_suffix = '.rst'
39+
source_suffix = ".rst"
4340

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

4744
# The master toctree document.
48-
master_doc = 'index'
45+
master_doc = "index"
4946

5047
# General information about the project.
51-
project = u'napalm-yang'
52-
copyright = u'2017, David Barroso'
48+
project = u"napalm-yang"
49+
copyright = u"2017, David Barroso"
5350

5451
# The version info for the project you're documenting, acts as replacement for
5552
# |version| and |release|, also used in various other places throughout the
5653
# built documents.
5754
#
5855
# The short X.Y version.
59-
version = '0'
56+
version = "0"
6057
# The full version, including alpha/beta/rc tags.
61-
release = '1'
58+
release = "1"
6259

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

7370
# List of patterns, relative to source directory, that match files and
7471
# directories to ignore when looking for source files.
75-
exclude_patterns = ['_build']
72+
exclude_patterns = ["_build"]
7673

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

9289
# The name of the Pygments (syntax highlighting) style to use.
93-
pygments_style = 'sphinx'
90+
pygments_style = "sphinx"
9491

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

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

108105
if not on_rtd: # only import and set the theme if we're building docs locally
109106
import sphinx_rtd_theme
110-
html_theme = 'sphinx_rtd_theme'
107+
108+
html_theme = "sphinx_rtd_theme"
111109
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
112110
else:
113-
html_theme = 'default'
111+
html_theme = "default"
114112

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

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

190188
# Output file base name for HTML help builder.
191-
htmlhelp_basename = 'napalmdoc'
189+
htmlhelp_basename = "napalmdoc"
192190

193191

194192
# -- Options for LaTeX output ---------------------------------------------
195193

196194
latex_elements = {
197195
# The paper size ('letterpaper' or 'a4paper').
198196
# 'papersize': 'letterpaper',
199-
200197
# The font size ('10pt', '11pt' or '12pt').
201198
# 'pointsize': '10pt',
202-
203199
# Additional stuff for the LaTeX preamble.
204200
# 'preamble': '',
205201
}
@@ -208,8 +204,7 @@
208204
# (source start file, target name, title,
209205
# author, documentclass [howto, manual, or own class]).
210206
latex_documents = [
211-
('index', 'napalm.tex', u'NAPALM Documentation',
212-
u'David Barroso', 'manual'),
207+
("index", "napalm.tex", u"NAPALM Documentation", u"David Barroso", "manual")
213208
]
214209

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

238233
# One entry per manual page. List of tuples
239234
# (source start file, name, description, authors, manual section).
240-
man_pages = [
241-
('index', 'napalm', u'NAPALM Documentation',
242-
[u'David Barroso'], 1)
243-
]
235+
man_pages = [("index", "napalm", u"NAPALM Documentation", [u"David Barroso"], 1)]
244236

245237
# If true, show URL addresses after external links.
246238
# man_show_urls = False
@@ -252,9 +244,15 @@
252244
# (source start file, target name, title, author,
253245
# dir menu entry, description, category)
254246
texinfo_documents = [
255-
('index', 'napalm-yang', u'NAPALM YANG Documentation',
256-
u'David Barroso', 'napalm-yang', 'YANG framework for any device',
257-
'Miscellaneous'),
247+
(
248+
"index",
249+
"napalm-yang",
250+
u"NAPALM YANG Documentation",
251+
u"David Barroso",
252+
"napalm-yang",
253+
"YANG framework for any device",
254+
"Miscellaneous",
255+
)
258256
]
259257

260258
# Documents to append as an appendix to all manuals.

docs/developers/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ WIP. Information here is a bit chaotic, sorry about that.
77
:maxdepth: 1
88

99
profiles
10-
profiles/index
1110
writing_profiles
1211
parsers/index
1312
translators

docs/developers/parsers/dynamic_directives.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@
4343
<td style="vertical-align: top;"> list, leaf</td>
4444
<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>
4545
On <b>leaves</b>, regexp will assign as value the capture group <code class="docutils literal">value</code></td>
46+
</tr>
47+
<tr>
48+
<th style="vertical-align: top;"> pre</th>
49+
<td style="vertical-align: top;"> leaf</td>
50+
<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>
4651
</tr>
4752
<tr>
4853
<th style="vertical-align: top;"> value</th>
4954
<td style="vertical-align: top;"> leaf</td>
50-
<td style="vertical-align: top;"> Post processing/formatting of the value</td>
55+
<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>
5156
</tr>
5257
<tr>
5358
<th style="vertical-align: top;"> map</th>

0 commit comments

Comments
 (0)