python-pylan 0.0.2__py3-none-any.whl → 0.0.3__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.
- pylan/__init__.py +17 -2
- pylan/__main__.py +29 -0
- pylan/cli/__init__.py +25 -0
- pylan/cli/cli.py +36 -0
- pylan/cli/receive.py +201 -0
- pylan/cli/scan.py +103 -0
- pylan/cli/send.py +106 -0
- pylan/client/__init__.py +14 -0
- pylan/core/__init__.py +103 -0
- pylan/core/discovery.py +475 -0
- pylan/core/handshake.py +145 -0
- pylan/core/models.py +77 -0
- pylan/core/net.py +88 -0
- pylan/core/protocol.py +132 -0
- pylan/core/transfer.py +420 -0
- pylan/errors/__init__.py +28 -0
- pylan/errors/base.py +13 -0
- pylan/main.py +6 -0
- pylan/ui/__init__.py +21 -0
- pylan/ui/app.py +188 -0
- pylan/ui/assets/icon.ico +0 -0
- pylan/ui/assets/icon.png +0 -0
- pylan/ui/assets/logo.svg +51 -0
- pylan/ui/components/__init__.py +14 -0
- pylan/ui/components/file_picker.py +243 -0
- pylan/ui/components/navbar.py +250 -0
- pylan/ui/components/peer_tile.py +152 -0
- pylan/ui/components/transfer_row.py +224 -0
- pylan/ui/state.py +823 -0
- pylan/ui/views/__init__.py +13 -0
- pylan/ui/views/home_view.py +245 -0
- pylan/ui/views/receive_view.py +249 -0
- pylan/ui/views/send_view.py +200 -0
- pylan/ui/views/settings_view.py +233 -0
- pylan/utils/utils.py +21 -0
- {python_pylan-0.0.2.dist-info → python_pylan-0.0.3.dist-info}/METADATA +13 -3
- python_pylan-0.0.3.dist-info/RECORD +39 -0
- {python_pylan-0.0.2.dist-info → python_pylan-0.0.3.dist-info}/WHEEL +1 -1
- python_pylan-0.0.3.dist-info/entry_points.txt +2 -0
- python_pylan-0.0.2.dist-info/RECORD +0 -4
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"""Settings view for configuring device identity, networking, and storage."""
|
|
2
|
+
|
|
3
|
+
import inspect
|
|
4
|
+
from typing import Any, Callable, Optional
|
|
5
|
+
|
|
6
|
+
import flet as ft
|
|
7
|
+
|
|
8
|
+
from pylan.ui.state import AppState
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def show_notice(page: Any, text: str) -> None:
|
|
12
|
+
"""Display an informational notification bar.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
page: Flet Page instance.
|
|
16
|
+
text: Message string to present.
|
|
17
|
+
"""
|
|
18
|
+
if page is None:
|
|
19
|
+
return
|
|
20
|
+
snack = ft.SnackBar(content=ft.Text(text))
|
|
21
|
+
if hasattr(page, "show_dialog"):
|
|
22
|
+
page.show_dialog(snack)
|
|
23
|
+
elif hasattr(page, "show_snack_bar"):
|
|
24
|
+
page.show_snack_bar(snack)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def create_settings_view(
|
|
28
|
+
state: AppState,
|
|
29
|
+
folder_picker: Optional[ft.FilePicker] = None,
|
|
30
|
+
on_back_click: Optional[Callable[[], None]] = None,
|
|
31
|
+
page_width: Optional[float] = None,
|
|
32
|
+
) -> ft.Control:
|
|
33
|
+
"""Construct the Settings configuration view.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
state: Reactive application state store.
|
|
37
|
+
folder_picker: Optional FilePicker instance for directory selection.
|
|
38
|
+
on_back_click: Optional callback to return to the home screen.
|
|
39
|
+
page_width: Optional viewport width for responsive layout adjustments.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
A Flet Control containing the application settings form.
|
|
43
|
+
"""
|
|
44
|
+
settings = state.settings
|
|
45
|
+
|
|
46
|
+
_ = on_back_click
|
|
47
|
+
is_mobile = page_width is not None and page_width < 500
|
|
48
|
+
alias_field = ft.TextField(
|
|
49
|
+
label="Device Name",
|
|
50
|
+
value=settings.device_alias,
|
|
51
|
+
prefix_icon=ft.Icons.BADGE_ROUNDED,
|
|
52
|
+
dense=True,
|
|
53
|
+
border=ft.OutlineInputBorder(border_radius=8),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
model_field = ft.TextField(
|
|
57
|
+
label="Device Model",
|
|
58
|
+
value=settings.device_model,
|
|
59
|
+
prefix_icon=ft.Icons.LAPTOP_ROUNDED,
|
|
60
|
+
dense=True,
|
|
61
|
+
border=ft.OutlineInputBorder(border_radius=8),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
port_field = ft.TextField(
|
|
65
|
+
label="Connection Port",
|
|
66
|
+
value=str(settings.tcp_port),
|
|
67
|
+
prefix_icon=ft.Icons.LAN_ROUNDED,
|
|
68
|
+
dense=True,
|
|
69
|
+
border=ft.OutlineInputBorder(border_radius=8),
|
|
70
|
+
keyboard_type=ft.KeyboardType.NUMBER,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
download_dir_field = ft.TextField(
|
|
74
|
+
label="Save Location",
|
|
75
|
+
value=settings.download_dir,
|
|
76
|
+
prefix_icon=ft.Icons.FOLDER_ROUNDED,
|
|
77
|
+
dense=True,
|
|
78
|
+
expand=True,
|
|
79
|
+
border=ft.OutlineInputBorder(border_radius=8),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
async def handle_browse_folder(_: Any = None) -> None:
|
|
83
|
+
if folder_picker is not None:
|
|
84
|
+
try:
|
|
85
|
+
res = folder_picker.get_directory_path()
|
|
86
|
+
path = await res if inspect.isawaitable(res) else res
|
|
87
|
+
if path:
|
|
88
|
+
download_dir_field.value = str(path)
|
|
89
|
+
if (
|
|
90
|
+
hasattr(download_dir_field, "page")
|
|
91
|
+
and download_dir_field.page
|
|
92
|
+
):
|
|
93
|
+
download_dir_field.update()
|
|
94
|
+
except Exception:
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
browse_folder_btn = ft.FilledTonalButton(
|
|
98
|
+
"Browse",
|
|
99
|
+
icon=ft.Icons.FOLDER_OPEN_ROUNDED,
|
|
100
|
+
height=40,
|
|
101
|
+
on_click=handle_browse_folder,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
auto_accept_switch = ft.Switch(
|
|
105
|
+
label="Automatically accept files from nearby devices",
|
|
106
|
+
value=settings.auto_accept,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
timeout_field = ft.TextField(
|
|
110
|
+
label="Device Search Timeout (seconds)",
|
|
111
|
+
value=str(settings.discovery_timeout),
|
|
112
|
+
prefix_icon=ft.Icons.TIMER_ROUNDED,
|
|
113
|
+
dense=True,
|
|
114
|
+
border=ft.OutlineInputBorder(border_radius=8),
|
|
115
|
+
keyboard_type=ft.KeyboardType.NUMBER,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
def handle_save(e: Any = None) -> None:
|
|
119
|
+
page = getattr(getattr(e, "control", None), "page", None)
|
|
120
|
+
new_alias = (alias_field.value or "").strip()
|
|
121
|
+
new_model = (model_field.value or "").strip()
|
|
122
|
+
new_dir = (download_dir_field.value or "").strip()
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
new_port = int(port_field.value or "44000")
|
|
126
|
+
if not (1024 <= new_port <= 65535):
|
|
127
|
+
raise ValueError("Port must be between 1024 and 65535")
|
|
128
|
+
except ValueError:
|
|
129
|
+
show_notice(
|
|
130
|
+
page, "Invalid port: enter a number (1024-65535)"
|
|
131
|
+
)
|
|
132
|
+
return
|
|
133
|
+
|
|
134
|
+
try:
|
|
135
|
+
new_timeout = float(timeout_field.value or "3.0")
|
|
136
|
+
if new_timeout <= 0:
|
|
137
|
+
raise ValueError()
|
|
138
|
+
except ValueError:
|
|
139
|
+
new_timeout = 3.0
|
|
140
|
+
|
|
141
|
+
state.update_settings(
|
|
142
|
+
alias=new_alias,
|
|
143
|
+
device_model=new_model,
|
|
144
|
+
port=new_port,
|
|
145
|
+
download_dir=new_dir,
|
|
146
|
+
auto_accept=bool(auto_accept_switch.value),
|
|
147
|
+
discovery_timeout=new_timeout,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
show_notice(page, "Settings saved successfully.")
|
|
151
|
+
|
|
152
|
+
def create_section(
|
|
153
|
+
title: str, icon: Any, controls: list[ft.Control]
|
|
154
|
+
) -> ft.Container:
|
|
155
|
+
return ft.Container(
|
|
156
|
+
content=ft.Column(
|
|
157
|
+
controls=[
|
|
158
|
+
ft.Row(
|
|
159
|
+
controls=[
|
|
160
|
+
ft.Icon(icon, size=20, color=ft.Colors.PRIMARY),
|
|
161
|
+
ft.Text(
|
|
162
|
+
title,
|
|
163
|
+
size=15,
|
|
164
|
+
weight=ft.FontWeight.BOLD,
|
|
165
|
+
color=ft.Colors.ON_SURFACE,
|
|
166
|
+
),
|
|
167
|
+
],
|
|
168
|
+
spacing=8,
|
|
169
|
+
),
|
|
170
|
+
ft.Divider(height=1, color=ft.Colors.OUTLINE_VARIANT),
|
|
171
|
+
*controls,
|
|
172
|
+
],
|
|
173
|
+
spacing=12,
|
|
174
|
+
),
|
|
175
|
+
padding=12 if is_mobile else 16,
|
|
176
|
+
border_radius=12,
|
|
177
|
+
bgcolor=ft.Colors.SURFACE_CONTAINER,
|
|
178
|
+
border=ft.Border.all(1, ft.Colors.OUTLINE_VARIANT),
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
identity_section = create_section(
|
|
182
|
+
"Device Identity",
|
|
183
|
+
ft.Icons.PERSON_ROUNDED,
|
|
184
|
+
[alias_field, model_field],
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
network_section = create_section(
|
|
188
|
+
"Network Preferences",
|
|
189
|
+
ft.Icons.WIFI_ROUNDED,
|
|
190
|
+
[
|
|
191
|
+
port_field,
|
|
192
|
+
timeout_field,
|
|
193
|
+
],
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
storage_section = create_section(
|
|
197
|
+
"Storage Preferences",
|
|
198
|
+
ft.Icons.SAVE_ROUNDED,
|
|
199
|
+
[
|
|
200
|
+
ft.Row(
|
|
201
|
+
controls=[download_dir_field, browse_folder_btn],
|
|
202
|
+
spacing=8,
|
|
203
|
+
),
|
|
204
|
+
auto_accept_switch,
|
|
205
|
+
],
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
save_btn = ft.FilledButton(
|
|
209
|
+
"Save Settings",
|
|
210
|
+
icon=ft.Icons.CHECK_ROUNDED,
|
|
211
|
+
height=42,
|
|
212
|
+
expand=True if is_mobile else False,
|
|
213
|
+
on_click=handle_save,
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
return ft.ListView(
|
|
217
|
+
controls=[
|
|
218
|
+
identity_section,
|
|
219
|
+
network_section,
|
|
220
|
+
storage_section,
|
|
221
|
+
ft.Row(
|
|
222
|
+
controls=[save_btn],
|
|
223
|
+
alignment=(
|
|
224
|
+
ft.MainAxisAlignment.CENTER
|
|
225
|
+
if is_mobile
|
|
226
|
+
else ft.MainAxisAlignment.END
|
|
227
|
+
),
|
|
228
|
+
),
|
|
229
|
+
],
|
|
230
|
+
spacing=12 if is_mobile else 16,
|
|
231
|
+
padding=12 if is_mobile else 20,
|
|
232
|
+
expand=True,
|
|
233
|
+
)
|
pylan/utils/utils.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import qrcode
|
|
2
|
+
import io
|
|
3
|
+
import base64
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def generate_qr_base64(data):
|
|
7
|
+
qr = qrcode.QRCode(
|
|
8
|
+
version=1,
|
|
9
|
+
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
|
10
|
+
box_size=10,
|
|
11
|
+
border=4
|
|
12
|
+
)
|
|
13
|
+
qr.add_data(data)
|
|
14
|
+
qr.make(fit=True)
|
|
15
|
+
|
|
16
|
+
from qrcode.image.pure import PyPNGImage
|
|
17
|
+
|
|
18
|
+
img = qr.make_image(image_factory=PyPNGImage)
|
|
19
|
+
buf = io.BytesIO()
|
|
20
|
+
img.save(buf)
|
|
21
|
+
return base64.b64encode(buf.getvalue()).decode("ascii")
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-pylan
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: Cross-platform local network file and data sharing library.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Aryan-202/python-pylan
|
|
6
|
-
Author: Aryan Vishwakarma
|
|
6
|
+
Author-email: Aryan Vishwakarma <aryanvishwakarma275@gmail.com>
|
|
7
7
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
8
8
|
Classifier: Intended Audience :: Developers
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Requires-Dist: asyncio>=4.0.0
|
|
13
|
+
Requires-Dist: bleak>=3.0.2
|
|
14
|
+
Requires-Dist: certifi>=2026.10.23
|
|
15
|
+
Requires-Dist: click>=8.5.0
|
|
16
|
+
Requires-Dist: flet>=1.0.5
|
|
17
|
+
Requires-Dist: psutil>=7.2.2
|
|
18
|
+
Requires-Dist: pytest>=9.1.1
|
|
19
|
+
Requires-Dist: qrcode>=8.2
|
|
20
|
+
Requires-Dist: scapy>=2.8.0
|
|
21
|
+
Requires-Dist: zeroconf>=0.151.5
|
|
12
22
|
Description-Content-Type: text/markdown
|
|
13
23
|
|
|
14
24
|
# PyLan
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
pylan/__init__.py,sha256=swLPgrcpzICsl6RJXWPGXU19G0qIWBPjLDDAc_JU1zY,605
|
|
2
|
+
pylan/__main__.py,sha256=EERZCM9LxKr0RfrA3O0Jbp3zDilZJ1Mk3bJ8QkgbpnI,729
|
|
3
|
+
pylan/main.py,sha256=BOIbt_uWoiGQmeQpNoVbk7TCYLbfHfHvRYb-rDVmBnI,122
|
|
4
|
+
pylan/cli/__init__.py,sha256=nVnWpHxKzjRJOeAlpicN8GzVIJTRu90DbzonATuf5Zc,771
|
|
5
|
+
pylan/cli/cli.py,sha256=3bbySBxtE4kyly3qb5-7pMNjM_KlwvrTsHtg2_P-dG0,788
|
|
6
|
+
pylan/cli/receive.py,sha256=nT_6jlyRLn0CEnn_RvhWdccMrYzauI5EPol6vdbKRKs,6486
|
|
7
|
+
pylan/cli/scan.py,sha256=sRCeh4E3-JV_YeEYTk77GXD-VbzyT9_Q96l5hDuQHLg,3058
|
|
8
|
+
pylan/cli/send.py,sha256=4ZQqN_EOTuKnOGcSxwW4sjaEvKhenxEq88TBOKKzChQ,3001
|
|
9
|
+
pylan/client/__init__.py,sha256=2nBWdmQvaYTTUl9ag7BxM4YLSNMMyeQc2npjBS9QtzU,377
|
|
10
|
+
pylan/core/__init__.py,sha256=uFoiIwc0v66OlGPjoVitB-MD-zkYddteI4khYe16CPY,2714
|
|
11
|
+
pylan/core/discovery.py,sha256=V1BWca-BFGB5bsvKCPlOUdrEJ8CMgIt1HOLWXF6hpRM,18122
|
|
12
|
+
pylan/core/handshake.py,sha256=w9V8QOSLw1TBG0jl16atkEqxKF74Nr_Lb3ovOP31juo,5355
|
|
13
|
+
pylan/core/models.py,sha256=vcn6mVtUzykwNHSs9RtaiPhoeHpuNVEPDAXhOQEXW7k,2009
|
|
14
|
+
pylan/core/net.py,sha256=um1m9N_xuUepOJFb_LXIpJ8JhrDnzmA0YHudw-Ox3dE,2743
|
|
15
|
+
pylan/core/protocol.py,sha256=nlEKAwJjkTVFUt4EA32BC3Hb4fgPtvrnMZyWP5ZGjzk,4429
|
|
16
|
+
pylan/core/transfer.py,sha256=evNh1PEfZJmQMJ2j44ZOmPYm8pS66AzD1BB6FfJy4us,14294
|
|
17
|
+
pylan/errors/__init__.py,sha256=ANVHeDAYhGaoEP8C7WbEa2TRTb1WM8uWrM4E77-1bXI,689
|
|
18
|
+
pylan/errors/base.py,sha256=PHfhOxEtrnYges9kHP5cGIOHBlFVkjVFj19Y1vR8oYM,354
|
|
19
|
+
pylan/ui/__init__.py,sha256=tRxgo4T9IDeseRDYALGXB323Uqo-0L0a9X2V6yLdFR0,463
|
|
20
|
+
pylan/ui/app.py,sha256=BFjIftf-CCEEMQKSY8-kSstcOzZemej0bGLoudc21H4,5644
|
|
21
|
+
pylan/ui/state.py,sha256=qV2-BqwvTqw7WiEdoKn7RxIqgdUj2dfgDCN34VY0Mv4,28326
|
|
22
|
+
pylan/ui/assets/icon.ico,sha256=Bw-UOxD8wBLjb76Liy1V8MtqyHU-iOBJlm2HMFjMJBc,3607
|
|
23
|
+
pylan/ui/assets/icon.png,sha256=Us-d_nceN3WCXuazV1-mrbbLeXcuOB1JbYU1swmWe2k,3585
|
|
24
|
+
pylan/ui/assets/logo.svg,sha256=SP5PkVryD-pd7L6lgMOcah6UzA0PYGXkcYg-Siws_gY,2565
|
|
25
|
+
pylan/ui/components/__init__.py,sha256=pNlycoHTZ9mKFBmu47hd-DoUFQ2HNMznJuRK5YDlrWE,480
|
|
26
|
+
pylan/ui/components/file_picker.py,sha256=qWO3tefkvfcSzvf6jDjrLb9_dN1D95XGomobXv_75qs,8885
|
|
27
|
+
pylan/ui/components/navbar.py,sha256=cVRKvRZCnUFbloQl4MQut5Q1zZTSaLsTdBhyjPQEJtM,8127
|
|
28
|
+
pylan/ui/components/peer_tile.py,sha256=-UYYfG_EcvMtIq8TBbhko-PDiVZy-_BceyQ9KE9EpQw,5373
|
|
29
|
+
pylan/ui/components/transfer_row.py,sha256=lYEEWITI6WHnUIaQQ3nZqG0qyGBypeHCSoLkdGNGLRM,7780
|
|
30
|
+
pylan/ui/views/__init__.py,sha256=CkSOxAkAXCGrTP5S3v2_Ug7BqlttOqmmY1FY5uXIVCA,415
|
|
31
|
+
pylan/ui/views/home_view.py,sha256=r2hprv-GUqG-8MtD0bqpAdMmTLVshWQUMfn1Axtg0w4,8894
|
|
32
|
+
pylan/ui/views/receive_view.py,sha256=DgPSp54t6IH0F-LNbh4Aj5_H-lRnpL5lDI4dG9Z-b7M,8835
|
|
33
|
+
pylan/ui/views/send_view.py,sha256=soPUORmHOWZHKNItej5ot8gf66xQzkIl8WH5wX-0o0c,6493
|
|
34
|
+
pylan/ui/views/settings_view.py,sha256=-i4G7KRmTj0X1FFPWw6NB3Q1xy-C4qZhWtNkcGCn4Ps,7048
|
|
35
|
+
pylan/utils/utils.py,sha256=Ikg045XjdayssYDLVU2F5xcjYzSmP7EbdJ12aajlzaQ,458
|
|
36
|
+
python_pylan-0.0.3.dist-info/METADATA,sha256=I7KDnzqwQujTKRtcT9_jKq0CwT3gEAs41Byz_hl4QJw,2507
|
|
37
|
+
python_pylan-0.0.3.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
38
|
+
python_pylan-0.0.3.dist-info/entry_points.txt,sha256=WU5o26RvjropBQYKv-rUi3VdGUoR4hfuI3ITkv4VweM,42
|
|
39
|
+
python_pylan-0.0.3.dist-info/RECORD,,
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
pylan/__init__.py,sha256=EjJejUMf1bZ6hupql9jm0v0sWuLn-iSPJ-pyD58R0xw,87
|
|
2
|
-
python_pylan-0.0.2.dist-info/METADATA,sha256=ZpadTGssGQtsqDUbQKliiKLgn619A76QM1Vvc61Qaaw,2174
|
|
3
|
-
python_pylan-0.0.2.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
4
|
-
python_pylan-0.0.2.dist-info/RECORD,,
|