gpath.platform
1from __future__ import annotations 2 3from enum import IntEnum, auto, unique 4 5 6__all__ = ('Platform', 'canonical_platform_names', 'platform_names') 7 8 9@unique 10class Platform(IntEnum): 11 """ 12 An Enum representing the different types of operating systems recognised by GPath. 13 14 This is used either when rendering output to a specific target platform, or to enforce maximum correctness when instantiating a new GPath from a specific origin platform. The latter use-case is not required for most normal file paths. 15 16 A Platform object can be obtained using `Platform.from_str()`. 17 """ 18 19 GENERIC = 0 20 POSIX = auto() 21 WINDOWS = auto() 22 23 @staticmethod 24 def from_str(name: str) -> Platform: 25 """ 26 Get the Platform object associated with a given platform name. 27 28 Valid platform names are listed in `platform_names`. 29 """ 30 return platform_names[name] 31 32 def __str__(self) -> str: 33 """ 34 Return the name of the platform as a string. 35 """ 36 return _name_of_platforms[self] 37 38 39canonical_platform_names: dict[str, Platform] = { 40 'generic': Platform.GENERIC, 41 'posix': Platform.POSIX, 42 'windows': Platform.WINDOWS, 43} 44"""Canonical platform names and the Platform enum that they map to""" 45 46platform_names: dict[str, Platform] = { 47 **canonical_platform_names, 48 '': Platform.GENERIC, 49 'linux': Platform.POSIX, 50 'macos': Platform.POSIX, 51} 52"""Valid platform names and the Platform enum that they map to""" 53 54 55_name_of_platforms: dict[Platform, str] = {v: k for k, v in canonical_platform_names.items()}
@unique
class
Platform10@unique 11class Platform(IntEnum): 12 """ 13 An Enum representing the different types of operating systems recognised by GPath. 14 15 This is used either when rendering output to a specific target platform, or to enforce maximum correctness when instantiating a new GPath from a specific origin platform. The latter use-case is not required for most normal file paths. 16 17 A Platform object can be obtained using `Platform.from_str()`. 18 """ 19 20 GENERIC = 0 21 POSIX = auto() 22 WINDOWS = auto() 23 24 @staticmethod 25 def from_str(name: str) -> Platform: 26 """ 27 Get the Platform object associated with a given platform name. 28 29 Valid platform names are listed in `platform_names`. 30 """ 31 return platform_names[name] 32 33 def __str__(self) -> str: 34 """ 35 Return the name of the platform as a string. 36 """ 37 return _name_of_platforms[self]
An Enum representing the different types of operating systems recognised by GPath.
This is used either when rendering output to a specific target platform, or to enforce maximum correctness when instantiating a new GPath from a specific origin platform. The latter use-case is not required for most normal file paths.
A Platform object can be obtained using Platform.from_str().
GENERIC =
<Platform.GENERIC: 0>
POSIX =
<Platform.POSIX: 1>
WINDOWS =
<Platform.WINDOWS: 2>
24 @staticmethod 25 def from_str(name: str) -> Platform: 26 """ 27 Get the Platform object associated with a given platform name. 28 29 Valid platform names are listed in `platform_names`. 30 """ 31 return platform_names[name]
Get the Platform object associated with a given platform name.
Valid platform names are listed in platform_names.
def
__str__(self) -> str:
33 def __str__(self) -> str: 34 """ 35 Return the name of the platform as a string. 36 """ 37 return _name_of_platforms[self]
Return the name of the platform as a string.
Inherited Members
- enum.Enum
- __signature__
- __dir__
- __reduce_ex__
- __deepcopy__
- __copy__
- name
- value
- enum.IntEnum
- __repr__
- builtins.int
- __hash__
- __getattribute__
- __lt__
- __le__
- __eq__
- __ne__
- __gt__
- __ge__
- __add__
- __radd__
- __sub__
- __rsub__
- __mul__
- __rmul__
- __mod__
- __rmod__
- __divmod__
- __rdivmod__
- __pow__
- __rpow__
- __neg__
- __pos__
- __abs__
- __bool__
- __invert__
- __lshift__
- __rlshift__
- __rshift__
- __rrshift__
- __and__
- __rand__
- __xor__
- __rxor__
- __or__
- __ror__
- __int__
- __float__
- __floordiv__
- __rfloordiv__
- __truediv__
- __rtruediv__
- __index__
- conjugate
- bit_length
- bit_count
- to_bytes
- from_bytes
- as_integer_ratio
- __trunc__
- __floor__
- __ceil__
- __round__
- __getnewargs__
- __sizeof__
- is_integer
- real
- imag
- numerator
- denominator
- builtins.object
- __setattr__
- __delattr__
- __reduce__
- __getstate__
- __subclasshook__
- __init_subclass__
canonical_platform_names: dict[str, platform.Platform] =
{'generic': <Platform.GENERIC: 0>, 'posix': <Platform.POSIX: 1>, 'windows': <Platform.WINDOWS: 2>}
Canonical platform names and the Platform enum that they map to
platform_names: dict[str, platform.Platform] =
{'generic': <Platform.GENERIC: 0>, 'posix': <Platform.POSIX: 1>, 'windows': <Platform.WINDOWS: 2>, '': <Platform.GENERIC: 0>, 'linux': <Platform.POSIX: 1>, 'macos': <Platform.POSIX: 1>}
Valid platform names and the Platform enum that they map to