Skip to content

Commit c3aea14

Browse files
committed
Add black and pylint
1 parent 65885eb commit c3aea14

11 files changed

+430
-257
lines changed

Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ name = "pypi"
77
grpcio-tools = "*"
88
googleapis-common-protos = "*"
99
pylint = "*"
10+
black = "*"
11+
twine = "*"
1012

1113
[packages]
1214
grpcio = "*"

Pipfile.lock

Lines changed: 122 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,50 @@
11
# nx-os-grpc-python
2+
3+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
5+
26
NX-OS gRPC Python connectivity library. Proto files sourced from [documentation](https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/7-x/programmability/guide/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide_7x/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide_7x_chapter_010111.html#id_41517).
37

48
## Development
5-
Requires Python and `pipenv`.
9+
Requires Python and recommends `pipenv`. Manual usage of `pip`/`virtualenv` is not covered. Uses `black` for code formatting and `pylint` for code linting.
10+
11+
### Get Source
612

713
```bash
814
git clone https://github.com/cisco-grpc-connection-libs/nx-os-grpc-python.git
915
cd nx-os-grpc-python
10-
# If Pipenv not installed...
16+
# If pipenv not installed, install!
1117
pip install --user pipenv
18+
# Now use pipenv, source from lockfile
19+
pipenv --three install --dev --ignore-pipfile
20+
# If that doesn't work..
1221
pipenv --three install --dev
22+
# If you encounter an issue locking dependencies...
23+
./lock_deps.sh
24+
# Enter virtual environment
1325
pipenv shell
1426
# Do your thing.
1527
exit
1628
```
1729

18-
## TLS Usage
19-
TODO: Where to acquire gRPC Agent RPM?
20-
In order to use a secure channel you must acquire the necessary gRPC PEM files, `grpc.pem`. This PEM file is found with your downloaded gRPC Agent RPM. You must then specify the file path or the content of this PEM file when initializing the Client class.
30+
### Clean Code
31+
We use [`black`](https://github.com/ambv/black) for code formatting and `pylint` for code linting. `clean_code.sh` will run `black` against all of the code under `nxos_grpc/` except for `protoc` compiled protobufs, and run `pylint` against Python files directly under `nxos_grpc/`. They don't totally agree, and we aren't using perfect naming conventions in some cases, so we're not looking for perfection here.
32+
33+
```bash
34+
./clean_code.sh
35+
```
36+
37+
TODO: Add pre-commit hook to automatically run black if any Python files are being committed.
2138

2239
### Recompile Protobufs
2340
If a new `nxos_grpc.proto` definition is released, use `update_protos.sh` to recompile. If breaking changes are introduced the wrapper library must be updated.
2441

2542
```bash
26-
pipenv shell
2743
./update_protos.sh
28-
exit
2944
```
45+
46+
47+
## TLS Usage
48+
In order to use a secure channel you must acquire the necessary gRPC PEM files, `grpc.pem`. This PEM file is found with your downloaded gRPC Agent RPM. You must then specify the file path or the content of this PEM file when initializing the Client class.
49+
50+
TODO: Where to acquire gRPC Agent RPM?

clean_code.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
pipenv run black --safe --verbose --exclude pb2 nxos_grpc
3+
pipenv run pylint nxos_grpc/*.py

lock_deps.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
pipenv lock --dev --clear
3+
pipenv run pip freeze > requirements.txt

nxos_grpc/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1+
"""
2+
Copyright 2018 Cisco Systems
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
"""
116
from .client import Client

0 commit comments

Comments
 (0)