pyhabitat 1.0.15__tar.gz → 1.0.16__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.

Potentially problematic release.


This version of pyhabitat might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhabitat
3
- Version: 1.0.15
3
+ Version: 1.0.16
4
4
  Summary: A lightweight library for detecting system environment, GUI, and build properties.
5
5
  Author-email: George Clayton Bennett <george.bennett@memphistn.gov>
6
6
  License-Expression: MIT
@@ -89,10 +89,12 @@ Key question: "What is the character of my executable?"
89
89
  | Function | Description |
90
90
  | :--- | :--- |
91
91
  | `is_frozen()` | Returns `True` if the script is running as a standalone executable (any bundler). |
92
+ | `is_pyinstaller()` | Returns `True` if the script is_frozen() and was generated by Pyinstaller (has MEI). |
92
93
  | `is_pipx()` | Returns `True` if running from a pipx managed virtual environment. |
93
94
  | `is_elf()` | Checks if the executable is an ELF binary (Linux standalone executable), excluding pipx. |
94
95
  | `is_windows_portable_executable()` | Checks if the executable is a Windows PE binary (MZ header), excluding pipx. |
95
- | `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. |
96
+ | `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. || `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. |
97
+
96
98
 
97
99
  ### Capability Checking
98
100
 
@@ -110,7 +112,7 @@ Key Question: "What could I do next?"
110
112
 
111
113
  | Function | Description |
112
114
  | :--- | :--- |
113
- | `open_text_file_for_editing()` | Smoothly opens a text file for editing (for configuration editing prompted by a CLI flag). |
115
+ | `edit_textfile()` | Smoothly opens a text file for editing (for configuration editing prompted by a CLI flag). |
114
116
 
115
117
  </details>
116
118
 
@@ -177,7 +179,7 @@ Use this function to smoothly open a text file for editing.
177
179
  Ideal use case: Edit a configuration file, if prompted by a CLI command like 'config --textedit'.
178
180
 
179
181
  ```python
180
- open_text_file_for_editing(filepath=Path('./config.json'))
182
+ edit_textfile(filepath=Path('./config.json'))
181
183
  ```
182
184
  </details>
183
185
 
@@ -74,10 +74,12 @@ Key question: "What is the character of my executable?"
74
74
  | Function | Description |
75
75
  | :--- | :--- |
76
76
  | `is_frozen()` | Returns `True` if the script is running as a standalone executable (any bundler). |
77
+ | `is_pyinstaller()` | Returns `True` if the script is_frozen() and was generated by Pyinstaller (has MEI). |
77
78
  | `is_pipx()` | Returns `True` if running from a pipx managed virtual environment. |
78
79
  | `is_elf()` | Checks if the executable is an ELF binary (Linux standalone executable), excluding pipx. |
79
80
  | `is_windows_portable_executable()` | Checks if the executable is a Windows PE binary (MZ header), excluding pipx. |
80
- | `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. |
81
+ | `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. || `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. |
82
+
81
83
 
82
84
  ### Capability Checking
83
85
 
@@ -95,7 +97,7 @@ Key Question: "What could I do next?"
95
97
 
96
98
  | Function | Description |
97
99
  | :--- | :--- |
98
- | `open_text_file_for_editing()` | Smoothly opens a text file for editing (for configuration editing prompted by a CLI flag). |
100
+ | `edit_textfile()` | Smoothly opens a text file for editing (for configuration editing prompted by a CLI flag). |
99
101
 
100
102
  </details>
101
103
 
@@ -162,7 +164,7 @@ Use this function to smoothly open a text file for editing.
162
164
  Ideal use case: Edit a configuration file, if prompted by a CLI command like 'config --textedit'.
163
165
 
164
166
  ```python
165
- open_text_file_for_editing(filepath=Path('./config.json'))
167
+ edit_textfile(filepath=Path('./config.json'))
166
168
  ```
167
169
  </details>
168
170
 
@@ -174,4 +176,4 @@ Contributions are welcome\! If you find an environment or build system that is n
174
176
 
175
177
  ## 📄 License
176
178
 
177
- This project is licensed under the MIT License. See the LICENSE file for details.
179
+ This project is licensed under the MIT License. See the LICENSE file for details.
@@ -11,7 +11,7 @@ from .environment import (
11
11
  is_windows,
12
12
  is_apple,
13
13
  is_ish_alpine,
14
- pyinstaller,
14
+ is_pyinstaller,
15
15
  is_frozen,
16
16
  is_elf,
17
17
  is_pyz,
@@ -20,7 +20,7 @@ from .environment import (
20
20
  is_pipx,
21
21
  interactive_terminal_is_available,
22
22
  web_browser_is_available,
23
- open_text_file_for_editing,
23
+ edit_textfile,
24
24
  )
25
25
 
26
26
  # Optional: Set __all__ for explicit documentation and cleaner imports
@@ -35,7 +35,7 @@ __all__ = [
35
35
  'is_windows',
36
36
  'is_apple',
37
37
  'is_ish_alpine',
38
- 'pyinstaller',
38
+ 'is_pyinstaller',
39
39
  'is_frozen',
40
40
  'is_elf',
41
41
  'is_pyz',
@@ -44,5 +44,5 @@ __all__ = [
44
44
  'is_pipx',
45
45
  'interactive_terminal_is_available',
46
46
  'web_browser_is_available',
47
- 'open_text_file_for_editing',
48
- ]
47
+ 'edit_textfile',
48
+ ]
@@ -211,7 +211,7 @@ def is_ish_alpine() -> bool:
211
211
 
212
212
  # --- BUILD AND EXECUTABLE CHECKS ---
213
213
 
214
- def pyinstaller():
214
+ def is_pyinstaller():
215
215
  """Detects if the Python script is running as a 'frozen' in the course of generating a PyInstaller binary executable."""
216
216
  # If the app is frozen AND has the PyInstaller-specific temporary folder path
217
217
  return is_frozen() and hasattr(sys, '_MEIPASS')
@@ -448,36 +448,39 @@ def web_browser_is_available() -> bool:
448
448
  return False
449
449
 
450
450
  # --- LAUNCH MECHANISMS BASED ON ENVIRONMENT ---
451
- def open_text_file_for_editing(filepath):
451
+ def edit_textfile(filepath) -> None:
452
+ #def open_text_file_for_editing(filepath):
452
453
  """
453
454
  Opens a file with the environment's default application (Windows, Linux, macOS)
454
455
  or a guaranteed console editor (nano) in constrained environments (Termux, iSH)
455
456
  after ensuring line-ending compatibility.
456
457
  """
457
- if is_windows():
458
- os.startfile(filepath)
459
- elif is_termux():
460
- # Install dependencies if missing (Termux pkg returns non-zero if already installed, so no check=True)
461
- subprocess.run(['pkg','install', 'dos2unix', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
462
- _run_dos2unix(filepath)
463
- subprocess.run(['nano', filepath])
464
- elif is_ish_alpine():
465
- # Install dependencies if missing (apk returns 0 if already installed, so check=True is safe)
466
- subprocess.run(['apk','add', 'dos2unix'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
467
- subprocess.run(['apk','add', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
468
- _run_dos2unix(filepath)
469
- subprocess.run(['nano', filepath])
470
- # --- Standard Unix-like Systems (Conversion + Default App) ---
471
- elif is_linux():
472
- _run_dos2unix(filepath) # Safety conversion for user-defined console apps
473
- subprocess.run(['xdg-open', filepath])
474
-
475
- elif is_apple():
476
- _run_dos2unix(filepath) # Safety conversion for user-defined console apps
477
- subprocess.run(['open', filepath])
478
- else:
479
- print("Unsupported operating system.")
480
-
458
+ try:
459
+ if is_windows():
460
+ os.startfile(filepath)
461
+ elif is_termux():
462
+ # Install dependencies if missing (Termux pkg returns non-zero if already installed, so no check=True)
463
+ subprocess.run(['pkg','install', 'dos2unix', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
464
+ _run_dos2unix(filepath)
465
+ subprocess.run(['nano', filepath])
466
+ elif is_ish_alpine():
467
+ # Install dependencies if missing (apk returns 0 if already installed, so check=True is safe)
468
+ subprocess.run(['apk','add', 'dos2unix'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
469
+ subprocess.run(['apk','add', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
470
+ _run_dos2unix(filepath)
471
+ subprocess.run(['nano', filepath])
472
+ # --- Standard Unix-like Systems (Conversion + Default App) ---
473
+ elif is_linux():
474
+ _run_dos2unix(filepath) # Safety conversion for user-defined console apps
475
+ subprocess.run(['xdg-open', filepath])
476
+ elif is_apple():
477
+ _run_dos2unix(filepath) # Safety conversion for user-defined console apps
478
+ subprocess.run(['open', filepath])
479
+ else:
480
+ print("Unsupported operating system.")
481
+ except Exception as e:
482
+ print("The file could not be opened for editing in the current environment. Known failure points: Pydroid3")
483
+
481
484
  """Why Not Use check=True on Termux:
482
485
  The pkg utility in Termux is a wrapper around Debian's apt. When you run pkg install <package>, if the package is already installed, the utility often returns an exit code of 100 (or another non-zero value) to indicate that no changes were made because the package was already present.
483
486
  """
@@ -530,4 +533,4 @@ def _check_if_zip(file_path: str | Path) -> bool:
530
533
  except Exception:
531
534
  # Handle cases where the path might be invalid, or other unexpected errors
532
535
  return False
533
-
536
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhabitat
3
- Version: 1.0.15
3
+ Version: 1.0.16
4
4
  Summary: A lightweight library for detecting system environment, GUI, and build properties.
5
5
  Author-email: George Clayton Bennett <george.bennett@memphistn.gov>
6
6
  License-Expression: MIT
@@ -89,10 +89,12 @@ Key question: "What is the character of my executable?"
89
89
  | Function | Description |
90
90
  | :--- | :--- |
91
91
  | `is_frozen()` | Returns `True` if the script is running as a standalone executable (any bundler). |
92
+ | `is_pyinstaller()` | Returns `True` if the script is_frozen() and was generated by Pyinstaller (has MEI). |
92
93
  | `is_pipx()` | Returns `True` if running from a pipx managed virtual environment. |
93
94
  | `is_elf()` | Checks if the executable is an ELF binary (Linux standalone executable), excluding pipx. |
94
95
  | `is_windows_portable_executable()` | Checks if the executable is a Windows PE binary (MZ header), excluding pipx. |
95
- | `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. |
96
+ | `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. || `is_macos_executable()` | Checks if the executable is a macOS/Darwin Mach-O binary, excluding pipx. |
97
+
96
98
 
97
99
  ### Capability Checking
98
100
 
@@ -110,7 +112,7 @@ Key Question: "What could I do next?"
110
112
 
111
113
  | Function | Description |
112
114
  | :--- | :--- |
113
- | `open_text_file_for_editing()` | Smoothly opens a text file for editing (for configuration editing prompted by a CLI flag). |
115
+ | `edit_textfile()` | Smoothly opens a text file for editing (for configuration editing prompted by a CLI flag). |
114
116
 
115
117
  </details>
116
118
 
@@ -177,7 +179,7 @@ Use this function to smoothly open a text file for editing.
177
179
  Ideal use case: Edit a configuration file, if prompted by a CLI command like 'config --textedit'.
178
180
 
179
181
  ```python
180
- open_text_file_for_editing(filepath=Path('./config.json'))
182
+ edit_textfile(filepath=Path('./config.json'))
181
183
  ```
182
184
  </details>
183
185
 
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "pyhabitat"
9
- version = "1.0.15"
9
+ version = "1.0.16"
10
10
  #dynamic = ["version"] #
11
11
  authors = [
12
12
  { name="George Clayton Bennett", email="george.bennett@memphistn.gov" },
@@ -28,4 +28,4 @@ include = ["pyhabitat"] # Only include the main package
28
28
 
29
29
  [tool.setuptools_scm]
30
30
  # This tells setuptools_scm to look at your git history/tags for the version
31
- write_to = "pyhabitat/_version.py"
31
+ write_to = "pyhabitat/_version.py"
File without changes
File without changes