Skip to content

Commit a4a20b2

Browse files
committed
Move nodes example into examples/ directory
Add a copyright header amd so on, and update the Sphinx examples file to just source from the file.
1 parent ec9fa8a commit a4a20b2

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

docs/examples.rst

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
Examples
22
========
33

4-
Basic query for nodes using :mod:`pypuppetdb`::
4+
Basic query for nodes using :mod:`pypuppetdb`:
55

6-
import pypuppetdb
7-
import pypuppetdbquery
8-
9-
pdb = pypuppetdb.connect()
10-
11-
pdb_ast = pypuppetdbquery.parse(
12-
'(processorcount=4 or processorcount=8) and kernel=Linux')
13-
14-
for node in pdb.nodes(query=pdb_ast):
15-
print(node)
6+
.. literalinclude:: ../examples/nodes.py
7+
:lines: 21-

examples/nodes.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of pypuppetdbquery.
4+
# Copyright © 2016 Chris Boot <[email protected]>
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
"""
18+
Query for nodes using :mod:`pypuppetdb`.
19+
"""
20+
21+
import pypuppetdb
22+
import pypuppetdbquery
23+
24+
pdb = pypuppetdb.connect()
25+
26+
pdb_ast = pypuppetdbquery.parse(
27+
'(processorcount=4 or processorcount=8) and kernel=Linux')
28+
29+
for node in pdb.nodes(query=pdb_ast):
30+
print(node)

0 commit comments

Comments
 (0)