mac-formatter-gui 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,8 @@
1
+ """MAC Address Formatter GUI package.
2
+
3
+ Provides a simple Tkinter application to normalize and format MAC addresses
4
+ into common styles and copy them to the clipboard.
5
+ """
6
+
7
+ __all__ = ["__version__"]
8
+ __version__ = "0.1.0"
mac_formatter/app.py ADDED
@@ -0,0 +1,178 @@
1
+ import tkinter as tk
2
+ from tkinter import ttk, messagebox
3
+ import re
4
+
5
+ APP_TITLE = "MAC Address Formatter"
6
+
7
+
8
+ def clean_mac(text: str) -> str:
9
+ """Return only hex characters from the input string."""
10
+ if not text:
11
+ return ""
12
+ return re.sub(r"[^0-9a-fA-F]", "", text)
13
+
14
+
15
+ def is_valid_mac12(hex_only: str) -> bool:
16
+ """Validate the string has exactly 12 hex digits (48-bit MAC)."""
17
+ return bool(re.fullmatch(r"[0-9a-fA-F]{12}", hex_only))
18
+
19
+
20
+ def format_mac(hex_only: str, style: str = ":", case: str = "upper") -> str:
21
+ """
22
+ Format 12-hex-digit MAC into specified style.
23
+ style options:
24
+ - ":" -> XX:XX:XX:XX:XX:XX
25
+ - "-" -> XX-XX-XX-XX-XX-XX
26
+ - "." -> XXXX.XXXX.XXXX
27
+ case options: "upper" or "lower"
28
+ """
29
+ if not is_valid_mac12(hex_only):
30
+ return ""
31
+
32
+ h = hex_only.upper() if case.lower() == "upper" else hex_only.lower()
33
+
34
+ if style == ".":
35
+ return f"{h[0:4]}.{h[4:8]}.{h[8:12]}"
36
+ elif style in (":", "-"):
37
+ pairs = [h[i:i+2] for i in range(0, 12, 2)]
38
+ return style.join(pairs)
39
+ else:
40
+ # default to colon style
41
+ pairs = [h[i:i+2] for i in range(0, 12, 2)]
42
+ return ":".join(pairs)
43
+
44
+
45
+ class MacFormatterApp(tk.Tk):
46
+ def __init__(self):
47
+ super().__init__()
48
+ self.title(APP_TITLE)
49
+ self.geometry("520x300")
50
+ self.minsize(480, 280)
51
+
52
+ self.case_var = tk.StringVar(value="upper")
53
+ self.input_var = tk.StringVar()
54
+ self.colon_var = tk.StringVar()
55
+ self.dash_var = tk.StringVar()
56
+ self.dot_var = tk.StringVar()
57
+
58
+ self._build_ui()
59
+ self._bind_events()
60
+
61
+ def _build_ui(self):
62
+ pad = {"padx": 8, "pady": 6}
63
+
64
+ # Input frame
65
+ in_frame = ttk.LabelFrame(self, text="Input")
66
+ in_frame.pack(fill="x", expand=False, **pad)
67
+
68
+ ttk.Label(in_frame, text="MAC address (any format):").grid(row=0, column=0, sticky="w", **pad)
69
+ self.input_entry = ttk.Entry(in_frame, textvariable=self.input_var, width=40)
70
+ self.input_entry.grid(row=0, column=1, sticky="we", **pad)
71
+ in_frame.columnconfigure(1, weight=1)
72
+
73
+ convert_btn = ttk.Button(in_frame, text="Convert", command=self.update_outputs)
74
+ convert_btn.grid(row=0, column=2, **pad)
75
+
76
+ clear_btn = ttk.Button(in_frame, text="Clear", command=self.clear_all)
77
+ clear_btn.grid(row=0, column=3, **pad)
78
+
79
+ # Case selection
80
+ case_frame = ttk.LabelFrame(self, text="Case")
81
+ case_frame.pack(fill="x", expand=False, **pad)
82
+ ttk.Radiobutton(case_frame, text="UPPERCASE", value="upper", variable=self.case_var, command=self.update_outputs).grid(row=0, column=0, **pad)
83
+ ttk.Radiobutton(case_frame, text="lowercase", value="lower", variable=self.case_var, command=self.update_outputs).grid(row=0, column=1, **pad)
84
+
85
+ # Output frame
86
+ out_frame = ttk.LabelFrame(self, text="Formats")
87
+ out_frame.pack(fill="both", expand=True, **pad)
88
+
89
+ # Colon format
90
+ ttk.Label(out_frame, text="Colon (XX:XX:...):").grid(row=0, column=0, sticky="w", **pad)
91
+ self.colon_entry = ttk.Entry(out_frame, textvariable=self.colon_var, state="readonly")
92
+ self.colon_entry.grid(row=0, column=1, sticky="we", **pad)
93
+ ttk.Button(out_frame, text="Copy", command=lambda: self.copy_to_clipboard(self.colon_var.get())).grid(row=0, column=2, **pad)
94
+
95
+ # Dash format
96
+ ttk.Label(out_frame, text="Dash (XX-XX-...):").grid(row=1, column=0, sticky="w", **pad)
97
+ self.dash_entry = ttk.Entry(out_frame, textvariable=self.dash_var, state="readonly")
98
+ self.dash_entry.grid(row=1, column=1, sticky="we", **pad)
99
+ ttk.Button(out_frame, text="Copy", command=lambda: self.copy_to_clipboard(self.dash_var.get())).grid(row=1, column=2, **pad)
100
+
101
+ # Dotted format
102
+ ttk.Label(out_frame, text="Dotted (XXXX.XXXX.XXXX):").grid(row=2, column=0, sticky="w", **pad)
103
+ self.dot_entry = ttk.Entry(out_frame, textvariable=self.dot_var, state="readonly")
104
+ self.dot_entry.grid(row=2, column=1, sticky="we", **pad)
105
+ ttk.Button(out_frame, text="Copy", command=lambda: self.copy_to_clipboard(self.dot_var.get())).grid(row=2, column=2, **pad)
106
+
107
+ out_frame.columnconfigure(1, weight=1)
108
+
109
+ # Status label
110
+ self.status_var = tk.StringVar()
111
+ self.status_label = ttk.Label(self, textvariable=self.status_var, foreground="#b00020")
112
+ self.status_label.pack(fill="x", padx=10, pady=(0, 8))
113
+
114
+ # Focus input on start
115
+ self.after(100, lambda: self.input_entry.focus_set())
116
+
117
+ def _bind_events(self):
118
+ # Update outputs when typing
119
+ self.input_entry.bind("<KeyRelease>", lambda e: self.update_outputs())
120
+
121
+ def clear_all(self):
122
+ self.input_var.set("")
123
+ self.colon_var.set("")
124
+ self.dash_var.set("")
125
+ self.dot_var.set("")
126
+ self.status_var.set("")
127
+ self.input_entry.focus_set()
128
+
129
+ def update_outputs(self):
130
+ raw = self.input_var.get().strip()
131
+ hex_only = clean_mac(raw)
132
+ case = self.case_var.get()
133
+
134
+ if not raw:
135
+ # Nothing entered
136
+ self.colon_var.set("")
137
+ self.dash_var.set("")
138
+ self.dot_var.set("")
139
+ self.status_var.set("")
140
+ return
141
+
142
+ if not is_valid_mac12(hex_only):
143
+ self.colon_var.set("")
144
+ self.dash_var.set("")
145
+ self.dot_var.set("")
146
+ if len(hex_only) == 0:
147
+ self.status_var.set("Enter 12 hex digits (48-bit MAC).")
148
+ else:
149
+ self.status_var.set(f"Invalid MAC: found {len(hex_only)} hex digits. Need 12.")
150
+ return
151
+
152
+ # Valid
153
+ self.status_var.set("")
154
+ self.colon_var.set(format_mac(hex_only, ":", case))
155
+ self.dash_var.set(format_mac(hex_only, "-", case))
156
+ self.dot_var.set(format_mac(hex_only, ".", case))
157
+
158
+ def copy_to_clipboard(self, text: str):
159
+ if not text:
160
+ self.bell()
161
+ return
162
+ try:
163
+ self.clipboard_clear()
164
+ self.clipboard_append(text)
165
+ # Ensure the clipboard is updated for other apps
166
+ self.update()
167
+ self.status_var.set("Copied to clipboard.")
168
+ except Exception as e:
169
+ messagebox.showerror("Clipboard Error", str(e))
170
+
171
+
172
+ def main():
173
+ app = MacFormatterApp()
174
+ app.mainloop()
175
+
176
+
177
+ if __name__ == "__main__":
178
+ main()
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: mac-formatter-gui
3
+ Version: 0.1.0
4
+ Summary: A simple Tkinter GUI to format MAC addresses into common styles and copy them to clipboard.
5
+ Author-email: Neil Johnson <apps@erudicon.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://example.com/mac-formatter-gui
8
+ Keywords: mac,mac address,formatter,gui,tkinter
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Environment :: Win32 (MS Windows)
14
+ Classifier: Topic :: Utilities
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Dynamic: license-file
19
+
20
+ # MAC Formatter GUI
21
+
22
+ A simple Tkinter GUI to normalize and display MAC addresses in three common formats:
23
+
24
+ - Colon: `XX:XX:XX:XX:XX:XX`
25
+ - Dash: `XX-XX-XX-XX-XX-XX`
26
+ - Dotted: `XXXX.XXXX.XXXX`
27
+
28
+ It also lets you choose UPPERCASE or lowercase and copy the results to your clipboard.
29
+
30
+ ## Installation
31
+
32
+ You can install from PyPI once published:
33
+
34
+ ```
35
+ pip install mac-formatter-gui
36
+ ```
37
+
38
+ For local development (from this repository root):
39
+
40
+ ```
41
+ pip install -e .
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ After installation, launch the app with the console command:
47
+
48
+ ```
49
+ mac-formatter
50
+ ```
51
+
52
+ Or via Python:
53
+
54
+ ```
55
+ python -m mac_formatter.app
56
+ ```
57
+
58
+ ## Requirements
59
+
60
+ - Python 3.8+
61
+ - Tkinter (comes with standard CPython on most platforms)
62
+
63
+ ## Development
64
+
65
+ Build and test the distribution locally:
66
+
67
+ ```
68
+ python -m build
69
+ ```
70
+
71
+ Upload to TestPyPI:
72
+
73
+ ```
74
+ python -m twine upload -r testpypi dist/*
75
+ ```
76
+
77
+ Upload to PyPI:
78
+
79
+ ```
80
+ python -m twine upload dist/*
81
+ ```
82
+
@@ -0,0 +1,8 @@
1
+ mac_formatter/__init__.py,sha256=KQxKrQvqYML9e_OyoPG-A_-V-dudweEBp50hkpgtpCY,227
2
+ mac_formatter/app.py,sha256=uqIgXJKF88alDsWqd-MR9K1LRj1YkGWHrk7tTnTIQ_8,6610
3
+ mac_formatter_gui-0.1.0.dist-info/licenses/LICENSE,sha256=gPtK3HlbZWT-ZJLPvfLUZSiGsrH8XqeYflsmTH6SiPc,1090
4
+ mac_formatter_gui-0.1.0.dist-info/METADATA,sha256=1Uf8qN0xHOzi0IJtu0xp2M2LSV7e8rKcXfRqE8Ahpf4,1706
5
+ mac_formatter_gui-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ mac_formatter_gui-0.1.0.dist-info/entry_points.txt,sha256=dd8RACRf2CdvPc31JQudX9o1xaJtFBOE3sYfjO3bQIE,57
7
+ mac_formatter_gui-0.1.0.dist-info/top_level.txt,sha256=lSJWi7qu3PNY9wO0O3U7pq00ZsX6hIifamJjwv6qyO8,14
8
+ mac_formatter_gui-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mac-formatter = mac_formatter.app:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Neil Johnson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ mac_formatter