diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml new file mode 100644 index 00000000..9acb14c6 --- /dev/null +++ b/.github/workflows/pythonapp.yml @@ -0,0 +1,31 @@ +name: Test code + +on: + push: + paths: + - "**/*.py" + pull_request: + paths: + - "**/*.py" + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Test with unittest + run: | + python -m unittest discover tests diff --git a/jc/parsers/arp.py b/jc/parsers/arp.py index 1d8e9d92..babffcd9 100644 --- a/jc/parsers/arp.py +++ b/jc/parsers/arp.py @@ -196,12 +196,13 @@ def parse(data, raw=False, quiet=False): raw_output = [] for line in cleandata: line = line.split() - output_line = {} - output_line['name'] = line[0] - output_line['address'] = line[1].lstrip('(').rstrip(')') - output_line['hwtype'] = line[4].lstrip('[').rstrip(']') - output_line['hwaddress'] = line[3] - output_line['iface'] = line[6] + output_line = { + 'name': line[0], + 'address': line[1].lstrip('(').rstrip(')'), + 'hwtype': line[4].lstrip('[').rstrip(']'), + 'hwaddress': line[3], + 'iface': line[6], + } raw_output.append(output_line) if raw: diff --git a/jc/parsers/blkid.py b/jc/parsers/blkid.py index d21353d3..b241acaf 100644 --- a/jc/parsers/blkid.py +++ b/jc/parsers/blkid.py @@ -150,8 +150,7 @@ def process(proc_data): for key in int_list: if key in entry: try: - key_int = int(entry[key]) - entry[key] = key_int + entry[key] = int(entry[key]) except (ValueError): entry[key] = None diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..0a08f111 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +ifconfig-parser>=0.0.5 +ruamel.yaml>=0.15.0 +xmltodict>=0.12.0