Skip to content

Commit

Permalink
Merge pull request #72 from fawaf/master
Browse files Browse the repository at this point in the history
add support for arrow notation in macos output
  • Loading branch information
benjaoming authored Apr 19, 2023
2 parents cbcaf1b + a395c4c commit 7f2cc2e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
clean: clean-build clean-pyc clean-test
all: build

install: clean
python setup.py install

build: clean
python setup.py build

clean: clean-build clean-pyc clean-test

clean-build: ## remove build artifacts
rm -fr build/
Expand Down Expand Up @@ -47,3 +54,6 @@ dist: clean ## Generate wheels distribution
python setup.py bdist_wheel
python setup.py sdist
ls -l dist

req:
pip install --requirement requirements_dev.txt
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ Before commiting and opening PRs, ensure that you have pre-commit hooks running:
Release notes
-------------

0.24
----

* add support for arrow notation inet #71

0.23
____

Expand Down
3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nose
mock
nose
pre-commit
tox
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: PyPy',
],
)
2 changes: 1 addition & 1 deletion src/ifcfg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from . import parser, tools

__version__ = "0.23"
__version__ = "0.24"

Log = tools.minimal_logger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions src/ifcfg/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'netmasks': 'LIST',
'broadcast': None,
'broadcasts': 'LIST',
'prefixlens': 'LIST',
'prefixlens': 'LIST',
}


Expand Down Expand Up @@ -242,7 +242,7 @@ def get_command(cls):
def get_patterns(cls):
return [
r'(?P<device>^[-a-zA-Z0-9:\.]+): flags=(?P<flags>.*) mtu (?P<mtu>\d+)',
r'.*inet\s+(?P<inet4>[\d\.]+)((\s+netmask\s)|\/)(?P<netmasks>[\w.]+)(\s+(brd|broadcast)\s(?P<broadcasts>[^\s]*))?.*',
r'.*inet\s+(?P<inet4>[\d\.]+)(\s+-->\s+(?P<_inet4>[\d\.]+))?((\s+netmask\s)|\/)(?P<netmasks>[\w.]+)((\s+(brd|broadcast)\s(?P<broadcasts>[^\s]*))?.*)?',
r'.*inet6\s+(?P<inet6>[\d\:abcdef]+)(%\w+)?((\s+prefixlen\s+)|\/)(?P<prefixlens>\d+)',
r'.*ether (?P<ether>[^\s]*).*',
]
Expand Down
2 changes: 2 additions & 0 deletions tests/ifconfig_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@
nd6 options=281<PERFORMNUD,INSECURE,DAD>
media: autoselect
status: active
utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1400
inet 10.63.73.73 --> 10.63.73.73 netmask 0xffffffff
"""

# See: https://github.com/ftao/python-ifcfg/issues/40
Expand Down
7 changes: 5 additions & 2 deletions tests/ifconfig_tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from nose.tools import eq_, ok_, raises

import ifcfg
from ifcfg.parser import LinuxParser, NullParser
from nose.tools import eq_, ok_, raises

from . import ifconfig_out
from .base import IfcfgTestCase
Expand Down Expand Up @@ -107,11 +108,13 @@ def test_macosx2(self):
ifcfg.Parser = ifcfg.get_parser_class()
parser = ifcfg.get_parser(ifconfig=ifconfig_out.MACOSX2)
interfaces = parser.interfaces
self.assertEqual(len(interfaces.keys()), 9)
self.assertEqual(len(interfaces.keys()), 10)
eq_(interfaces['lo0']['inet'], '127.0.0.1')
eq_(interfaces['lo0']['inet4'], ['127.0.0.1', '127.0.1.99'])
eq_(interfaces['lo0']['netmask'], '255.0.0.0')
eq_(interfaces['lo0']['netmasks'], ['255.0.0.0', '255.0.0.0'])
eq_(interfaces['utun3']['inet'], '10.63.73.73')
eq_(interfaces['utun3']['netmask'], '255.255.255.255')

def test_default_interface(self):
ifcfg.distro = 'Linux'
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
# Ensure you add to .travis.yml if you add here, using `tox -l`
envlist = py27,py34,py35,py36,py37,py38,lint
envlist = py27,py34,py35,py36,py37,py38,py39,py310,py311,lint

[travis]
python =
Expand All @@ -10,6 +10,9 @@ python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]

Expand All @@ -20,6 +23,9 @@ basepython =
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
py311: python3.11

commands =
python --version
Expand Down

0 comments on commit 7f2cc2e

Please sign in to comment.