pyloid 0.23.6__tar.gz → 0.23.8__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.3
2
2
  Name: pyloid
3
- Version: 0.23.6
3
+ Version: 0.23.8
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyloid"
3
- version = "0.23.6"
3
+ version = "0.23.8"
4
4
  description = ""
5
5
  authors = ["aesthetics-of-record <111675679+aesthetics-of-record@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -1211,7 +1211,9 @@ class _BrowserWindow:
1211
1211
 
1212
1212
  (JavaScript)
1213
1213
  ```javascript
1214
- document.addEventListener('customEvent', (data) => {
1214
+ import { event } from 'pyloid-js';
1215
+
1216
+ event.listen('customEvent', (data) => {
1215
1217
  console.log(data.message);
1216
1218
  });
1217
1219
  ```
@@ -2113,7 +2115,7 @@ class BrowserWindow(QObject):
2113
2115
  result = self._window.remove_shortcut(params["key_sequence"])
2114
2116
  elif command_type == "get_all_shortcuts":
2115
2117
  result = self._window.get_all_shortcuts()
2116
- elif command_type == "emit":
2118
+ elif command_type == "invoke":
2117
2119
  event_name = params["event_name"]
2118
2120
  data = params.get("data")
2119
2121
  result = self._window.invoke(event_name, data)
@@ -2668,9 +2670,13 @@ class BrowserWindow(QObject):
2668
2670
  >>> window.invoke("customEvent", {"message": "Hello, Pyloid!"})
2669
2671
 
2670
2672
  (JavaScript)
2671
- >>> document.addEventListener('customEvent', (data) => {
2672
- ... console.log(data.message);
2673
- ... });
2673
+ ```javascript
2674
+ import { event } from 'pyloid-js';
2675
+
2676
+ event.listen('customEvent', (data) => {
2677
+ console.log(data.message);
2678
+ });
2679
+ ```
2674
2680
  """
2675
2681
  return self.execute_command("invoke", {"event_name": event_name, "data": data})
2676
2682
 
@@ -7,23 +7,43 @@ import socket
7
7
 
8
8
  def get_production_path(path: Optional[str] = None) -> Optional[str]:
9
9
  """
10
- Returns the path to the resource files in a production environment.
11
- If running as a regular Python script, returns None.
10
+ Constructs the absolute path to a resource file, adjusting based on the execution environment.
11
+
12
+ In a production environment (e.g., when packaged with PyInstaller or Nuitka),
13
+ it prepends the application's base directory (sys._MEIPASS for PyInstaller,
14
+ or the directory of the executable for Nuitka) to the provided relative path.
15
+ If no path is provided, it returns the base path itself.
16
+
17
+ If not running in a production environment (e.g., during development as a regular
18
+ Python script), it simply returns the provided path as is. If no path is provided,
19
+ it returns None in a non-production environment.
20
+
21
+ Parameters
22
+ ----------
23
+ path : Optional[str], optional
24
+ The relative path to the resource file from the application's root directory.
25
+ Defaults to None.
12
26
 
13
27
  Returns
14
28
  -------
15
- str | None
16
- The path to the resource files if in a production environment,
17
- otherwise None.
29
+ Optional[str]
30
+ - If in production: The absolute path to the resource file (or the base path if `path` is None).
31
+ - If not in production: The original `path` value passed to the function.
18
32
 
19
33
  Examples
20
34
  --------
21
- >>> from pyloid.utils import get_production_path
22
- >>> path = get_production_path("assets/icon.ico")
23
- >>> if path:
24
- >>> print(f"Production path: {path}")
25
- >>> else:
26
- >>> print("Not in a production environment.")
35
+ >>> # Assume running NOT in production
36
+ >>> get_production_path("assets/icon.ico")
37
+ 'assets/icon.ico'
38
+ >>> get_production_path()
39
+ None
40
+
41
+ >>> # Assume running IN production (e.g., PyInstaller bundle)
42
+ >>> # where sys._MEIPASS might be '/tmp/_MEIabcde'
43
+ >>> get_production_path("assets/icon.ico") # doctest: +SKIP
44
+ '/tmp/_MEIabcde/assets/icon.ico'
45
+ >>> get_production_path() # doctest: +SKIP
46
+ '/tmp/_MEIabcde'
27
47
  """
28
48
  if is_production():
29
49
  if hasattr(sys, '_MEIPASS'):
@@ -40,7 +60,7 @@ def get_production_path(path: Optional[str] = None) -> Optional[str]:
40
60
 
41
61
  return os.path.join(base_path, path) if path else base_path
42
62
  else:
43
- return None
63
+ return path
44
64
 
45
65
 
46
66
  def is_production() -> bool:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes