hbutils.system.os.type
Operating system detection utilities.
This module provides a small set of cross-platform helpers for detecting the
current operating system using platform. The detection is cached to
avoid repeated system calls, and the API exposes simple boolean functions for
common OS checks.
The module contains the following public functions:
is_linux()- Check if the current OS is Linuxis_windows()- Check if the current OS is Windowsis_darwin()- Check if the current OS is Darwin/macOSis_macos- Alias ofis_darwin()
Note
The module internally uses an enum.IntEnum for OS identification,
but only the helper functions are considered public API.
Example:
>>> from hbutils.system.os.type import is_linux, is_windows, is_macos
>>> is_linux()
True
>>> is_windows()
False
>>> is_macos()
False
__all__
- hbutils.system.os.type.__all__ = ['is_linux', 'is_windows', 'is_macos', 'is_darwin']
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
is_macos
- hbutils.system.os.type.is_macos: Callable[[], bool] = <function is_darwin>
Alias of
is_darwin().This is a convenience alias for checking if the current operating system is macOS. It provides a more intuitive name while maintaining the same functionality as
is_darwin().
OSType
- class hbutils.system.os.type.OSType(value)[source]
Enumeration of supported operating system types.
This enum defines integer constants for different operating systems that can be detected by the
platformmodule. The enum is decorated withhbutils.model.enum.int_enum_loads()to support loading from string names via theloads()class method.- Variables:
LINUX – Linux operating system identifier.
WINDOWS – Windows operating system identifier.
DARWIN – Darwin/macOS operating system identifier.
JAVA – Java platform identifier.
is_linux
- hbutils.system.os.type.is_linux() bool[source]
Check if the current operating system is Linux.
Return
Trueif the current operating system is Linux, otherwise returnFalse.- Returns:
Whether the current OS is Linux.
- Return type:
bool
- Example::
>>> is_linux() # On a Linux system True >>> is_linux() # On a Windows system False
is_windows
- hbutils.system.os.type.is_windows() bool[source]
Check if the current operating system is Windows.
Return
Trueif the current operating system is Windows, otherwise returnFalse.- Returns:
Whether the current OS is Windows.
- Return type:
bool
- Example::
>>> is_windows() # On a Windows system True >>> is_windows() # On a Linux system False
is_darwin
- hbutils.system.os.type.is_darwin() bool[source]
Check if the current operating system is Darwin (macOS).
Return
Trueif the current operating system is Darwin, otherwise returnFalse.- Returns:
Whether the current OS is Darwin.
- Return type:
bool
Note
Darwin is macOS.
- Example::
>>> is_darwin() # On a macOS system True >>> is_darwin() # On a Linux system False