Skip to content

Commit

Permalink
Create python-package.yml and fix detected bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dannytrigo committed Apr 11, 2024
1 parent 9bdc995 commit 92fec0a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
8 changes: 4 additions & 4 deletions import_protocol_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def loop_rows(data):
row = row[:max_model_column]

# Remove whitespace from all fields
row = [unicode(s).strip() if s else s for s in row]
row = [str(s).strip() if s else s for s in row]

#print row

Expand Down Expand Up @@ -166,9 +166,9 @@ def loop_rows(data):
range = value
else:
# Parse the value - sometimes ranges are given, split those first
range = re.split(ur'(?<=[\u201c\u201d"”“])-(?=[\u201c\u201d"”“])', value)
range = re.split(r'(?<=[\u201c\u201d"”“])-(?=[\u201c\u201d"”“])', value)
# Then, remove the quotes
validate = lambda s: re.match(ur'^[\u201c\u201d”"”“](.*?)["”]$', s)
validate = lambda s: re.match(r'^[\u201c\u201d”"”“](.*?)["”]$', s)

range = [validate(r).groups()[0] for r in range]

Expand Down Expand Up @@ -210,7 +210,7 @@ def parse_support(s):
if not s:
return False

m = re.match(r'(Yes|No)(?:\(\*\))?', c)
m = re.match(r'(Yes|No)(?:\(\*\))?', s)
if not m:
# Sometimes it doesn't say Yes or No, but as string
# such as RS232C. It seems that this notes always
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
netifaces==0.11.0
xmltodict==0.13.0

0 comments on commit 92fec0a

Please sign in to comment.