pyhabitat 1.0.10__tar.gz → 1.0.12__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.10
3
+ Version: 1.0.12
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
@@ -123,7 +123,7 @@ The module exposes all detection functions directly for easy access.
123
123
 
124
124
  ### 0\. Current Use
125
125
 
126
- The `pipeline-eds` pacakge uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
126
+ The `pipeline-eds` package uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
127
127
 
128
128
  ### 1\. Checking Environment and Build Type
129
129
 
@@ -108,7 +108,7 @@ The module exposes all detection functions directly for easy access.
108
108
 
109
109
  ### 0\. Current Use
110
110
 
111
- The `pipeline-eds` pacakge uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
111
+ The `pipeline-eds` package uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
112
112
 
113
113
  ### 1\. Checking Environment and Build Type
114
114
 
@@ -18,7 +18,7 @@ from .environment import (
18
18
  is_windows_portable_executable,
19
19
  is_macos_executable,
20
20
  is_pipx,
21
- is_interactive_terminal,
21
+ interactive_terminal_is_available,
22
22
  web_browser_is_available,
23
23
  open_text_file_in_default_app,
24
24
  )
@@ -42,7 +42,7 @@ __all__ = [
42
42
  'is_windows_portable_executable',
43
43
  'is_macos_executable',
44
44
  'is_pipx',
45
- 'is_interactive_terminal',
45
+ 'interactive_terminal_is_available',
46
46
  'web_browser_is_available',
47
47
  'open_text_file_in_default_app',
48
48
  ]
@@ -449,22 +449,54 @@ def web_browser_is_available() -> bool:
449
449
  return False
450
450
 
451
451
  # --- LAUNCH MECHANISMS BASED ON ENVIRONMENT ---
452
- def open_text_file_in_default_app(filepath):
453
- """Opens a file with its default application based on the OS."""
452
+ def open_text_file_for_editing(filepath):
453
+ """
454
+ Opens a file with the environment's default application (Windows, Linux, macOS)
455
+ or a guaranteed console editor (nano) in constrained environments (Termux, iSH)
456
+ after ensuring line-ending compatibility.
457
+ """
454
458
  if is_windows():
455
459
  os.startfile(filepath)
456
460
  elif is_termux():
461
+ # Install dependencies if missing (Termux pkg returns non-zero if already installed, so no check=True)
462
+ subprocess.run(['pkg','install', 'dos2unix', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
463
+ _run_dos2unix(filepath)
457
464
  subprocess.run(['nano', filepath])
458
465
  elif is_ish_alpine():
459
- subprocess.run(['apk','add', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
466
+ # Install dependencies if missing (apk returns 0 if already installed, so check=True is safe)
467
+ subprocess.run(['apk','add', 'dos2unix'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
468
+ subprocess.run(['apk','add', 'nano'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
469
+ _run_dos2unix(filepath)
460
470
  subprocess.run(['nano', filepath])
471
+ # --- Standard Unix-like Systems (Conversion + Default App) ---
461
472
  elif is_linux():
473
+ _run_dos2unix(filepath) # Safety conversion for user-defined console apps
462
474
  subprocess.run(['xdg-open', filepath])
475
+
463
476
  elif is_apple():
477
+ _run_dos2unix(filepath) # Safety conversion for user-defined console apps
464
478
  subprocess.run(['open', filepath])
465
479
  else:
466
480
  print("Unsupported operating system.")
467
-
481
+
482
+ """Why Not Use check=True on Termux:
483
+ 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.
484
+ """
485
+
486
+ def _run_dos2unix(filepath):
487
+ """Attempt to run dos2unix, failing silently if not installed."""
488
+ try:
489
+ # We rely on shutil.which not being needed, as this is a robust built-in utility on most targets
490
+ # The command won't raise an exception unless the process itself fails, not just if the utility isn't found.
491
+ # We also don't use check=True here to allow silent failure if the utility is missing (e.g., minimalist Linux).
492
+ subprocess.run(['dos2unix', filepath], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
493
+ except FileNotFoundError:
494
+ # This will be raised if 'dos2unix' is not on the system PATH
495
+ pass
496
+ except Exception:
497
+ # Catch other subprocess errors (e.g. permission issues)
498
+ pass
499
+
468
500
  def _get_pipx_paths():
469
501
  """
470
502
  Returns the configured/default pipx binary and home directories.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhabitat
3
- Version: 1.0.10
3
+ Version: 1.0.12
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
@@ -123,7 +123,7 @@ The module exposes all detection functions directly for easy access.
123
123
 
124
124
  ### 0\. Current Use
125
125
 
126
- The `pipeline-eds` pacakge uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
126
+ The `pipeline-eds` package uses the `pyhabitat` library to handle [configuration](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/security_and_config.py) and [plotting](https://github.com/City-of-Memphis-Wastewater/pipeline/blob/main/src/pipeline/cli.py), among other things.
127
127
 
128
128
  ### 1\. Checking Environment and Build Type
129
129
 
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "pyhabitat"
9
- version = "1.0.10"
9
+ version = "1.0.12"
10
10
  #dynamic = ["version"] #
11
11
  authors = [
12
12
  { name="George Clayton Bennett", email="george.bennett@memphistn.gov" },
File without changes
File without changes