pyhabitat 1.0.15__py3-none-any.whl → 1.0.16__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.

Potentially problematic release.


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

pyhabitat/__init__.py CHANGED
@@ -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
+ ]
pyhabitat/environment.py CHANGED
@@ -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
 
@@ -0,0 +1,7 @@
1
+ pyhabitat/__init__.py,sha256=MiYIzYPqB3o6ZFXQ1C9BV2M2KI17BSq9CA6p8Uc7_h0,1096
2
+ pyhabitat/environment.py,sha256=v9e47TdbtMSiljkjr9-lfdUILQu95HLH0SB6k7QIba0,20757
3
+ pyhabitat-1.0.16.dist-info/licenses/LICENSE,sha256=D4fg30ctUGnCJlWu3ONv5-V8JE1v3ctakoJTcVjsJlg,1072
4
+ pyhabitat-1.0.16.dist-info/METADATA,sha256=APK_RIRIKYUzZ3nuNgcRUvbDhaHZnWXAwvatvPwU_Qg,9001
5
+ pyhabitat-1.0.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ pyhabitat-1.0.16.dist-info/top_level.txt,sha256=zXYK44Qu8EqxUETREvd2diMUaB5JiGRErkwFaoLQnnI,10
7
+ pyhabitat-1.0.16.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- pyhabitat/__init__.py,sha256=XVMOgp7YPR0xYD1F_4-VEhG4rTwx3ga3CttdRKpkyxA,1115
2
- pyhabitat/environment.py,sha256=K1It1gvUhYHXixIxHoEMl6grTwZJkGVWbt18_Qeh1qQ,20532
3
- pyhabitat-1.0.15.dist-info/licenses/LICENSE,sha256=D4fg30ctUGnCJlWu3ONv5-V8JE1v3ctakoJTcVjsJlg,1072
4
- pyhabitat-1.0.15.dist-info/METADATA,sha256=PrG9ruoa2F0RJzIogXh4GX55PUPWn0resJRITDnsqac,8813
5
- pyhabitat-1.0.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- pyhabitat-1.0.15.dist-info/top_level.txt,sha256=zXYK44Qu8EqxUETREvd2diMUaB5JiGRErkwFaoLQnnI,10
7
- pyhabitat-1.0.15.dist-info/RECORD,,