Skip to content

Commit 528a472

Browse files
authored
Add an example using parameterized (#146)
* Add an example using parameterized This is useful for templating both fetchers and checks. * Add flake8 to check demo too * Making pre-commit happy in demo * Fix doc warnings * Add documentation about the use of parameterized * Update CHANGES.md
1 parent 71ff18f commit 528a472

26 files changed

+331
-177
lines changed

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
ignore = P1,C812,C813,C814,C815,C816,W503
3+
max-line-length = 88

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# -*- mode: gitignore; -*-
22

33
# Sphinx documentation
4-
doc/_build/
5-
doc/modules.rst
6-
doc/compliance*.rst
7-
doc/.doctrees
4+
doc
85

96
### Emacs
107

.pre-commit-config.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ repos:
1717
rev: 5.0.4
1818
hooks:
1919
- id: flake8
20-
args: [
21-
--extend-ignore,
22-
"P1,C812,C813,C814,C815,C816,W503"
23-
]
2420
additional_dependencies: [
2521
flake8-2020,
2622
flake8-broken-line,
@@ -39,7 +35,7 @@ repos:
3935
flake8-use-fstring,
4036
pep8-naming
4137
]
42-
files: "^(compliance|test)"
38+
files: "^(compliance|test|demo)"
4339
stages: [commit]
4440
- repo: https://github.com/PyCQA/bandit
4541
rev: 1.7.4

CHANGES.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
- [FIXED] Update pre-commit dependencies.
44
- [CHANGED] Use python 3.8 in GitHub Actions as newer flake8 does not support less than that.
5-
- [CHANGED] Dot not update pre-commit hooks during "make develop"
5+
- [CHANGED] Dot not update pre-commit hooks during "make develop".
66
- [ADDED] Add basic pre-commit hooks.
7-
- [FIXED] Support for agent signing of binary content
8-
- [FIXED] Demo fetcher/check for World Clock API replaced with GitHub API example
7+
- [FIXED] Support for agent signing of binary content.
8+
- [FIXED] Demo fetcher/check for World Clock API replaced with GitHub API example.
9+
- [ADDED] Documentation about using @parameterized.
10+
- [CHANGED] Unify github demo code in one single place.
11+
- [FIXED] flake8 now scans demo code too.
912

1013
# [1.23.0](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v1.23.0)
1114

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ docs:
4646
# Build the API docs from the source code - overwrites those files, which are ignored by git
4747
sphinx-apidoc -o doc-source compliance
4848
sphinx-build doc-source $(DOC_TARGET)
49+
50+
clean-docs:
51+
$(RM) -r $(DOC_TARGET)

compliance/utils/credentials.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ def get(self, section, key=None, account=None, default=_sentinel):
9797
"""
9898
Retrieve sections and keys by account.
9999
100-
``section``: the section from which to retrieve keys.
101-
``key``: the key in the section whose value you want to retrieve. if
102-
not specified, returns the whole section as a dictionary.
103-
``account``: if provided, fetches the value for the specific account.
104-
assumes the account is prefixed to the key and separated by _.
105-
``default``: if provided, returns this value if a value cannot be
106-
found; otherwise raises an exception.
100+
:param section: the section from which to retrieve keys.
101+
:parm key: the key in the section whose value you want to retrieve. if
102+
not specified, returns the whole section as a dictionary.
103+
:param account: if provided, fetches the value for the specific account.
104+
assumes the account is prefixed to the key and separated by _.
105+
:param default: if provided, returns this value if a value cannot be
106+
found; otherwise raises an exception.
107107
"""
108108
if key is None:
109109
return self[section]

compliance/utils/data_parse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def parse_dot_key(data, key):
2525
2626
:param data: A dictionary
2727
:param key: A dictionary key string that may be a key path depicted by dot
28-
notation. For example "foo.bar".
28+
notation. For example "foo.bar".
2929
3030
:returns: The dictionary value from ``data`` associated to the ``key``.
3131
"""
@@ -74,8 +74,8 @@ def format_json(data, **addl_kwargs):
7474

7575

7676
def deep_merge(a, b, path=None, append=False):
77-
"""
78-
Merge two dicts, taking into account any sub (or sub-sub-*) dicts.
77+
r"""
78+
Merge two dicts, taking into account any sub (or sub-sub-\*) dicts.
7979
8080
If ``append`` is ``True`` then list values from ``b`` will be appended to
8181
``a``'s. Modified from: https://stackoverflow.com/a/7205107/566346

demo/auditree_demo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@
1414
"title": "Check results for demo.arboretum.accred accreditation"
1515
}
1616
}
17+
},
18+
"org": {
19+
"gh": {
20+
"orgs": ["nasa", "esa"]
21+
}
1722
}
1823
}

demo/controls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"arboretum.auditree.checks.test_python_packages.PythonPackageCheck": ["demo.arboretum.accred"],
3-
"demo_examples.checks.test_github_api_versions.GitHubAPIVersionsCheck": ["demo.custom.accred"],
3+
"demo_examples.checks.test_github.GitHubAPIVersionsCheck": ["demo.custom.accred"],
4+
"demo_examples.checks.test_github.GitHubOrgs": ["demo.custom.accred"],
45
"demo_examples.checks.test_image_content.ImageCheck": ["demo.custom.accred"]
56
}

demo/demo_examples/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
"""Demo module."""

0 commit comments

Comments
 (0)