pinter 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pinter-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: pinter
3
+ Version: 0.2.0
4
+ Summary: Print INTERfaces and ip addresses
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Author: Marcin Marzec
8
+ Requires-Python: >=3.8,<4.0
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Requires-Dist: psutil (>=5.9.6,<6.0.0)
20
+ Project-URL: Homepage, https://github.com/mmarzec/pinter
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Pinter - Print INTERfaces
24
+
25
+ Pinter is a small CLI tool that prints your network interfaces and their IP addresses in a clean, colored table. Forget about digging through `ifconfig` or `ip addr` output.
26
+
27
+ By default it shows only the interfaces that usually matter (Ethernet, Wi-Fi, bridges, VPN tunnels) and hides noise such as loopback, Docker and other virtual interfaces.
28
+
29
+ ## Features
30
+
31
+ - One line per interface, aligned columns, colored output
32
+ - All IPv4 addresses of an interface, when it has more than one
33
+ - Optional MAC addresses
34
+ - Optional view of all interfaces, without filtering
35
+ - Only one dependency: [psutil](https://github.com/giampaolo/psutil)
36
+
37
+ ## Installation
38
+
39
+ Install with `pipx` (preferred) or `pip`:
40
+
41
+ ```console
42
+ pipx install pinter
43
+ ```
44
+
45
+ ```console
46
+ pip install pinter
47
+ ```
48
+
49
+ Requires Python 3.8 or newer.
50
+
51
+ ## Usage
52
+
53
+ ```console
54
+ pinter [options]
55
+ ```
56
+
57
+ Options are single letters and can be combined in one argument, for example `pinter am`:
58
+
59
+ | Option | Description |
60
+ |--------|-----------------------------------------------------|
61
+ | `a` | Show all interfaces (no filtering) |
62
+ | `m` | Also print MAC addresses |
63
+ | `h` | Print help |
64
+
65
+ ### Default view
66
+
67
+ Shows only the important interfaces:
68
+
69
+ ```console
70
+ $ pinter
71
+ enp1s0 192.168.1.23
72
+ 192.168.1.24
73
+ wlp2s0 192.168.1.57
74
+ tun0 10.8.0.2
75
+ ```
76
+
77
+ Important addreses starts with: (`br`, `eno`, `enp`, `eth`, `wl`, `tun`).
78
+ Other addresses are hidden.
79
+
80
+
81
+ ### All interfaces
82
+
83
+ ```console
84
+ $ pinter a
85
+ lo 127.0.0.1
86
+ enp1s0 192.168.1.23
87
+ wlp2s0 192.168.1.57
88
+ docker0 172.17.0.1
89
+ ```
90
+
91
+ ### With MAC addresses
92
+
93
+ ```console
94
+ $ pinter m
95
+ enp1s0 192.168.1.23 52:54:00:12:34:56
96
+ wlp2s0 192.168.1.57 a4:c3:f0:65:43:21
97
+ ```
98
+
99
+ ### All interfaces with MAC addresses
100
+
101
+ ```console
102
+ $ pinter am
103
+ lo 127.0.0.1 00:00:00:00:00:00
104
+ enp1s0 192.168.1.23 52:54:00:12:34:56
105
+ wlp2s0 192.168.1.57 a4:c3:f0:65:43:21
106
+ docker0 172.17.0.1 02:42:7a:1b:2c:3d
107
+ ```
108
+
109
+ ## License
110
+
111
+ MIT, see [LICENSE](LICENSE).
112
+
pinter-0.2.0/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Pinter - Print INTERfaces
2
+
3
+ Pinter is a small CLI tool that prints your network interfaces and their IP addresses in a clean, colored table. Forget about digging through `ifconfig` or `ip addr` output.
4
+
5
+ By default it shows only the interfaces that usually matter (Ethernet, Wi-Fi, bridges, VPN tunnels) and hides noise such as loopback, Docker and other virtual interfaces.
6
+
7
+ ## Features
8
+
9
+ - One line per interface, aligned columns, colored output
10
+ - All IPv4 addresses of an interface, when it has more than one
11
+ - Optional MAC addresses
12
+ - Optional view of all interfaces, without filtering
13
+ - Only one dependency: [psutil](https://github.com/giampaolo/psutil)
14
+
15
+ ## Installation
16
+
17
+ Install with `pipx` (preferred) or `pip`:
18
+
19
+ ```console
20
+ pipx install pinter
21
+ ```
22
+
23
+ ```console
24
+ pip install pinter
25
+ ```
26
+
27
+ Requires Python 3.8 or newer.
28
+
29
+ ## Usage
30
+
31
+ ```console
32
+ pinter [options]
33
+ ```
34
+
35
+ Options are single letters and can be combined in one argument, for example `pinter am`:
36
+
37
+ | Option | Description |
38
+ |--------|-----------------------------------------------------|
39
+ | `a` | Show all interfaces (no filtering) |
40
+ | `m` | Also print MAC addresses |
41
+ | `h` | Print help |
42
+
43
+ ### Default view
44
+
45
+ Shows only the important interfaces:
46
+
47
+ ```console
48
+ $ pinter
49
+ enp1s0 192.168.1.23
50
+ 192.168.1.24
51
+ wlp2s0 192.168.1.57
52
+ tun0 10.8.0.2
53
+ ```
54
+
55
+ Important addreses starts with: (`br`, `eno`, `enp`, `eth`, `wl`, `tun`).
56
+ Other addresses are hidden.
57
+
58
+
59
+ ### All interfaces
60
+
61
+ ```console
62
+ $ pinter a
63
+ lo 127.0.0.1
64
+ enp1s0 192.168.1.23
65
+ wlp2s0 192.168.1.57
66
+ docker0 172.17.0.1
67
+ ```
68
+
69
+ ### With MAC addresses
70
+
71
+ ```console
72
+ $ pinter m
73
+ enp1s0 192.168.1.23 52:54:00:12:34:56
74
+ wlp2s0 192.168.1.57 a4:c3:f0:65:43:21
75
+ ```
76
+
77
+ ### All interfaces with MAC addresses
78
+
79
+ ```console
80
+ $ pinter am
81
+ lo 127.0.0.1 00:00:00:00:00:00
82
+ enp1s0 192.168.1.23 52:54:00:12:34:56
83
+ wlp2s0 192.168.1.57 a4:c3:f0:65:43:21
84
+ docker0 172.17.0.1 02:42:7a:1b:2c:3d
85
+ ```
86
+
87
+ ## License
88
+
89
+ MIT, see [LICENSE](LICENSE).
@@ -0,0 +1,86 @@
1
+ import psutil
2
+ import socket
3
+ import sys
4
+
5
+
6
+ def collect_intf_addresses(include_all=False):
7
+ interfaces_psutil = psutil.net_if_addrs()
8
+
9
+ intf_addresses = {}
10
+
11
+ # get all interfaces names
12
+ intf_names = (intf[1] for intf in socket.if_nameindex())
13
+
14
+ # filter
15
+ if not include_all:
16
+ intf_names = (intf for intf in intf_names if intf.startswith(('enp', 'eth', 'wl', 'eno', 'br', 'tun')))
17
+ intf_names = (intf for intf in intf_names if not intf.startswith(('br-')))
18
+
19
+ # get addresses
20
+ for intf in intf_names:
21
+ intf_addresses[intf] = {'ip': [], 'mac': ''}
22
+ for address in interfaces_psutil[intf]:
23
+ if address.family == socket.AF_INET:
24
+ intf_addresses[intf]['ip'].append(address.address)
25
+ elif address.family == socket.AF_PACKET:
26
+ intf_addresses[intf]['mac'] = address.address
27
+
28
+ return intf_addresses
29
+
30
+
31
+ def print_help():
32
+ print(f'''Description:
33
+ Print network interfaces and ip addresses
34
+
35
+ Usage:
36
+ pinter [options]
37
+
38
+ Options:
39
+ a all interfaces
40
+ h help
41
+ m print mac addresses
42
+
43
+ ''')
44
+
45
+
46
+ def cli():
47
+
48
+ # cli options
49
+ options = ''
50
+ if len(sys.argv) > 1:
51
+ options = sys.argv[1]
52
+
53
+ include_all = None
54
+ if 'a' in options:
55
+ include_all = True
56
+
57
+ if 'h' in options:
58
+ print_help()
59
+ return
60
+
61
+ include_mac = False
62
+ if 'm' in options:
63
+ include_mac = True
64
+
65
+ intf_addresses = collect_intf_addresses(include_all)
66
+ intf_col_width = len(max(intf_addresses.keys(), key=len, default=''))
67
+ ip_col_width = len(max([ip for intf in intf_addresses for ip in intf_addresses[intf]['ip']], key=len, default=''))
68
+
69
+ for intf in intf_addresses:
70
+ if not intf_addresses[intf]['ip']:
71
+ intf_addresses[intf]['ip'].append('')
72
+
73
+ # print first row
74
+ row = f'{intf:<{intf_col_width}} \033[36m{intf_addresses[intf]["ip"][0]:<{ip_col_width}}\033[0m'
75
+
76
+ if include_mac:
77
+ row = f'{row} \033[35m{intf_addresses[intf]["mac"]}\033[0m'
78
+ print(row)
79
+
80
+ # print rest rows
81
+ for ip_addr in intf_addresses[intf]['ip'][1:]:
82
+ print(f'{"":<{intf_col_width}} \033[36m{ip_addr}\033[0m')
83
+
84
+
85
+ if __name__ == "__main__":
86
+ cli()
@@ -1,15 +1,16 @@
1
1
  [tool.poetry]
2
2
  name = "pinter"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
+ license = "MIT"
4
5
  description = "Print INTERfaces and ip addresses"
5
6
  authors = ["Marcin Marzec"]
6
7
  readme = "README.md"
8
+ homepage = "https://github.com/mmarzec/pinter"
7
9
 
8
10
 
9
11
  [tool.poetry.dependencies]
10
12
  python = "^3.8"
11
13
  psutil = "^5.9.6"
12
- rich = "^13.7.0"
13
14
 
14
15
 
15
16
  [build-system]
pinter-0.1.0/PKG-INFO DELETED
@@ -1,37 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pinter
3
- Version: 0.1.0
4
- Summary: Print INTERfaces and ip addresses
5
- Author: Marcin Marzec
6
- Requires-Python: >=3.8,<4.0
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: Programming Language :: Python :: 3.8
9
- Classifier: Programming Language :: Python :: 3.9
10
- Classifier: Programming Language :: Python :: 3.10
11
- Classifier: Programming Language :: Python :: 3.11
12
- Classifier: Programming Language :: Python :: 3.12
13
- Requires-Dist: psutil (>=5.9.6,<6.0.0)
14
- Requires-Dist: rich (>=13.7.0,<14.0.0)
15
- Description-Content-Type: text/markdown
16
-
17
- # Pinter - Print INTERfaces
18
-
19
- Pinter is a CLI tool to print nicely your network interfaces and ip addresses. Forget about `ifconfig` or `ip addr`. It will filter out the ones that are not important like those create by docker, etc.
20
-
21
-
22
- ## Installation
23
- Install with `pipx`(prefered) or `pip`.
24
- ```console
25
- pipx install pinter
26
- ```
27
-
28
- ```console
29
- pip install pinter
30
- ```
31
-
32
- ## Usage
33
- Just run
34
- ```console
35
- pinter
36
- ```
37
-
pinter-0.1.0/README.md DELETED
@@ -1,20 +0,0 @@
1
- # Pinter - Print INTERfaces
2
-
3
- Pinter is a CLI tool to print nicely your network interfaces and ip addresses. Forget about `ifconfig` or `ip addr`. It will filter out the ones that are not important like those create by docker, etc.
4
-
5
-
6
- ## Installation
7
- Install with `pipx`(prefered) or `pip`.
8
- ```console
9
- pipx install pinter
10
- ```
11
-
12
- ```console
13
- pip install pinter
14
- ```
15
-
16
- ## Usage
17
- Just run
18
- ```console
19
- pinter
20
- ```
@@ -1,37 +0,0 @@
1
- import psutil
2
- import socket
3
- from rich.console import Console
4
- from rich.table import Table
5
-
6
-
7
- def collect_intf_addresses():
8
- interfaces_psutil = psutil.net_if_addrs()
9
-
10
- intf_addresses = {}
11
-
12
- # get all interfaces names
13
- intf_names = (intf[1] for intf in socket.if_nameindex())
14
-
15
- # filter
16
- intf_names = (intf for intf in intf_names if intf.startswith(('enp', 'eth', 'wl', 'eno', 'br', 'tun')))
17
- intf_names = (intf for intf in intf_names if not intf.startswith(('br-')))
18
-
19
- # get addresses
20
- for intf in intf_names:
21
- intf_addresses[intf] = None
22
- for address in interfaces_psutil[intf]:
23
- if address.family == socket.AF_INET:
24
- intf_addresses[intf] = address.address
25
-
26
- return intf_addresses
27
-
28
-
29
- def cli():
30
- table = Table(box=None)
31
- table.add_column()
32
- table.add_column(style="cyan")
33
- intf_addresses = collect_intf_addresses()
34
- for intf in intf_addresses:
35
- table.add_row(intf, intf_addresses[intf])
36
- console = Console()
37
- console.print(table)
File without changes
File without changes