Skip to content

Commit 98e0fb1

Browse files
authored
Merge pull request stfc#103 from khalford/workflow
File restructure and Linting
2 parents 0af0f3a + 2548d9f commit 98e0fb1

22 files changed

+113
-47
lines changed

.github/workflows/Pynetbox.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Pynetbox Data Uploader Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
paths:
9+
- "Pynetbox_Data_Uploader/**"
10+
- ".github/workflows/Pynetbox.yaml"
11+
12+
jobs:
13+
test_and_lint:
14+
runs-on: ubuntu-20.04
15+
strategy:
16+
matrix:
17+
python-version: ["3.x"]
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
cache: "pip"
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r Pynetbox_Data_Uploader/requirements.txt
30+
31+
- name: Run tests
32+
run: cd Pynetbox_Data_Uploader && python3 -m pytest .
33+
34+
- name: Analyse with pylint
35+
run: |
36+
cd Pynetbox_Data_Uploader && pylint $(git ls-files '*.py') --rcfile=.pylintrc
37+

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ venv/
55

66
.coverage
77
coverage.xml
8-
Netbox_CSV_Read/DataFiles

Pynetbox_Data_Uploader/.pylintrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[FORMAT]
2+
# Black will enforce 88 chars on Python code
3+
# this will enforce 120 chars on docs / comments
4+
max-line-length=120
5+
6+
# Disable various warnings:
7+
# C0114: Missing module string - we don't need module strings for the small repo
8+
# C0115: Missing class doc string - a lot of the actions are self explanatory
9+
# W0511: TODOs they're well....to do later
10+
# R0801: Similar lines - Imports and method signatures will flag this, such as forwarding action args
11+
# C0116: Missing method docstring - Adds too much noise
12+
# E0401: Ignore import errors as imports work
13+
14+
disable=C0114,C0115,E0401,W0511,R0801,C0116,E0401

Pynetbox_Data_Uploader/lib/__init__.py

Whitespace-only changes.

Pynetbox_Data_Uploader/lib/enums/__init__.py

Whitespace-only changes.

Netbox_CSV_Read/Enums/dcim_device_id.py renamed to Pynetbox_Data_Uploader/lib/enums/dcim_device_id.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class DeviceInfoID(Enum):
55
"""
66
This Enums Class stores enums that are used to retrieve data from Netbox.
77
"""
8+
89
DEVICE_ROLE = "dcim.device_roles"
910
DESCRIPTION = "dcim.devices"
1011
DEVICE_TYPE = "dcim.device_types"

Netbox_CSV_Read/Enums/dcim_device_no_id.py renamed to Pynetbox_Data_Uploader/lib/enums/dcim_device_no_id.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ class DeviceInfoNoID(Enum):
55
"""
66
This Enums Class stores enums that are used to retrieve data from Netbox.
77
"""
8-
position = "position"
9-
name = "name"
10-
serial = "serial"
11-
airflow = "airflow"
12-
status = "status"
13-
face = "face"
8+
9+
POSITION = "position"
10+
NAME = "name"
11+
SERIAL = "serial"
12+
AIRFLOW = "airflow"
13+
STATUS = "status"
14+
FACE = "face"

Pynetbox_Data_Uploader/lib/netbox_api/__init__.py

Whitespace-only changes.

Netbox_CSV_Read/CSV/format_dict.py renamed to Pynetbox_Data_Uploader/lib/netbox_api/format_dict.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from typing import Dict, List
2-
from Enums.dcim_device_id import DeviceInfoID
3-
from Enums.dcim_device_no_id import DeviceInfoNoID
4-
from Netbox_Api.netbox_connect import NetboxConnect
5-
from Netbox_Api.netbox_data import NetboxGetID
2+
from enums.dcim_device_id import DeviceInfoID
3+
from enums.dcim_device_no_id import DeviceInfoNoID
4+
from netbox_api.netbox_connect import NetboxConnect
5+
from netbox_api.netbox_data import NetboxGetID
66

77

88
class FormatDict(NetboxConnect):
99
"""
1010
This class takes dictionaries with string values and changes those to ID values from Netbox.
1111
"""
12+
1213
def __init__(self, dicts: list):
1314
"""
1415
This method initialises the class with the following parameters.

Netbox_CSV_Read/Netbox_Api/netbox_connect.py renamed to Pynetbox_Data_Uploader/lib/netbox_api/netbox_connect.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pynetbox as nb
22

3+
# pylint:disable = too-few-public-methods
4+
35

46
class NetboxConnect:
57
"""

0 commit comments

Comments
 (0)