difonlib 0.2.4__tar.gz → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: difonlib
3
- Version: 0.2.4
3
+ Version: 0.3.0
4
4
  Summary: python libraries
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "difonlib"
3
- version = "0.2.4"
3
+ version = "0.3.0"
4
4
  description = "python libraries"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -173,7 +173,7 @@ def bt_scan_hid_devs() -> list:
173
173
  async def bt_scan_devs( # universally version for classic and ble devices
174
174
  dev_type: str = "HID Device",
175
175
  inquiry_warmup: float = 4.0, # время для Classic Inquiry
176
- scan_duration: float = 6.0, # время bleak сканирования
176
+ scan_duration: float = 4.0, # время bleak сканирования
177
177
  adapter_path: str = "/org/bluez/hci0",
178
178
  ) -> list[dict]:
179
179
  bus = pydbus.SystemBus()
@@ -60,7 +60,7 @@ def is_remote_ctrl(dev: InputDevice) -> bool:
60
60
 
61
61
  def idev_get_dev_by_uniq(uniq: str) -> Optional[InputDevice]:
62
62
  devs = idev_get_connected_devs()
63
- matched = [dev for dev in devs if dev.uniq == uniq and is_remote_ctrl(dev)]
63
+ matched = [dev for dev in devs if dev.uniq.upper() == uniq.upper() and is_remote_ctrl(dev)]
64
64
  return matched[0] if matched else None
65
65
 
66
66
 
@@ -220,6 +220,10 @@ if __name__ == "__main__":
220
220
  # print_dicts_list(devs)
221
221
  # dbg(f"---------------------------------------------") # //Dima
222
222
  # exit()
223
+ # devs = idev_get_dev_by_uniq("40:B4:cd:CE:31:d6")
224
+ # print(f"devs: {devs}")
225
+ # exit()
226
+
223
227
  devs = idev_get_by_field("Name", "Keychron Keychron K5")
224
228
  if devs:
225
229
  for dev in devs:
@@ -182,9 +182,10 @@ def print_ctype_fields(
182
182
 
183
183
 
184
184
  class YamlConfig:
185
- def __init__(self, cfg_path: str):
185
+ def __init__(self, cfg_path: str, except_if_path_no_exist: bool = False, **init_vals: Any):
186
186
  self.config_path = Path(cfg_path)
187
- self.config: dict = {}
187
+ self.config: dict = init_vals
188
+ self.except_if_path_no_exist = except_if_path_no_exist
188
189
  self.load()
189
190
 
190
191
  def clear(self) -> None:
@@ -193,7 +194,10 @@ class YamlConfig:
193
194
 
194
195
  def load(self) -> None:
195
196
  if not self.config_path.exists():
196
- self.save()
197
+ if self.except_if_path_no_exist:
198
+ raise UtilsError(f"File '{self.config_path}' does not exists.")
199
+ else:
200
+ self.save()
197
201
  with self.config_path.open() as fcfg:
198
202
  self.config = yaml.safe_load(fcfg) or {}
199
203
 
@@ -209,4 +213,15 @@ class YamlConfig:
209
213
 
210
214
  if __name__ == "__main__":
211
215
  logdbg("Hello 0123456789 ABCDEF")
212
- cfg = YamlConfig("./___CONFIG.yaml")
216
+ cfg = YamlConfig(
217
+ "./___CONFIG.yaml",
218
+ # except_if_no_cfg_path=True,
219
+ infrared_devs={},
220
+ remctrl_types={},
221
+ remctrl_devs=set(),
222
+ )
223
+ cfg.config["remctrl_devs"].add("11:22:33:44:AA:55")
224
+ cfg.config["remctrl_devs"].add("AA:BB:CC:44:AA:55")
225
+ cfgrdevs: set = cfg.config["remctrl_devs"]
226
+ print(f"cfgrdevs: {cfgrdevs}")
227
+ cfg.save()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: difonlib
3
- Version: 0.2.4
3
+ Version: 0.3.0
4
4
  Summary: python libraries
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
File without changes
File without changes
File without changes
File without changes